nexushub-commands 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
5
5
  const evogram_1 = require("evogram");
6
6
  const migrated_1 = require("evogram/lib/migrated");
7
7
  const Client_1 = require("../../Client");
8
- const qs = require('qs');
9
8
  let CheckPaidOrderCommand = class CheckPaidOrderCommand extends migrated_1.Command {
10
9
  execute(context, orderId) {
11
10
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -5,8 +5,23 @@ const tslib_1 = require("tslib");
5
5
  const evogram_1 = require("evogram");
6
6
  const migrated_1 = require("evogram/lib/migrated");
7
7
  const Client_1 = require("../../Client");
8
- const GetDepositOrder_command_1 = require("./GetDepositOrder.command");
9
8
  const formatMessage_1 = require("../../utils/formatMessage");
9
+ const GetDepositOrder_command_1 = require("./GetDepositOrder.command");
10
+ // Функция для маскировки реквизитов: оставляет только последние 4 не пробельных символа
11
+ function maskExceptLast4(str) {
12
+ if (!str)
13
+ return '';
14
+ const chars = str.split('');
15
+ let nonSpaceCount = 0;
16
+ for (let i = chars.length - 1; i >= 0; i--) {
17
+ if (chars[i] !== ' ') {
18
+ nonSpaceCount++;
19
+ if (nonSpaceCount > 4)
20
+ chars[i] = '*';
21
+ }
22
+ }
23
+ return chars.join('');
24
+ }
10
25
  let DepositCommand = class DepositCommand extends evogram_1.Command {
11
26
  execute(context, method, coin, deposit) {
12
27
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -38,6 +53,9 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
38
53
  parse_mode: 'HTML',
39
54
  });
40
55
  }), 1000);
56
+ setTimeout(() => {
57
+ clearInterval(interval);
58
+ }, 300000);
41
59
  }
42
60
  const order = yield config.API.post(`orders`, {
43
61
  mirrorId: context.mammoth.mirror.mirror.id,
@@ -57,7 +75,7 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
57
75
  return context.sendFormatted({
58
76
  photo: config.images.deposit,
59
77
  header: '<b>❗️К сожалению, сейчас нет доступных реквизитов для оплаты.</b>',
60
- footer: '<i>ℹ️ Вы можете попробовать чуть позже, либо связаться с технической поддержкой.</i>',
78
+ footer: `<i>ℹ️ Вы можете попробовать чуть позже, воспользоваться другим способом оплаты, либо связаться с <a href="t.me/{{ ${config.support.username} }}">технической поддержкой</a>.</i>`,
61
79
  }, {
62
80
  reply_markup: {
63
81
  inline_keyboard: [[{ text: '👩‍💻 Поддержка', url: `t.me/${config.support.username}` }]],
@@ -71,7 +89,12 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
71
89
  to: 'RUB',
72
90
  ceiled: true,
73
91
  })})`
74
- : ''}`, {
92
+ : ``}`, {
93
+ // prettier-ignore
94
+ message: order.card ?
95
+ `<b>💳 Реквизиты:</b> <code>${maskExceptLast4(order.card.requisites)}</code>\n` +
96
+ `<b>👩🏻‍💼 Получатель:</b> ${order.card.holder || '-'}`
97
+ : '',
75
98
  keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
76
99
  });
77
100
  return context.redirect(GetDepositOrder_command_1.GetDepositOrderCommand, { orderId: order.id });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -1,8 +1,6 @@
1
1
  import { CommandArgument, CommandD } from 'evogram';
2
2
  import { Command, CommandContext } from 'evogram/lib/migrated';
3
3
  import { Client } from '../../Client';
4
- import axios from 'axios';
5
- const qs = require('qs');
6
4
 
7
5
  @CommandD({ name: 'checkPaidOrder' })
8
6
  export class CheckPaidOrderCommand extends Command {
@@ -1,8 +1,23 @@
1
- import { Command, CommandArgument, CommandD, Evogram, numberValidator } from 'evogram';
1
+ import { Command, CommandArgument, CommandD, numberValidator } from 'evogram';
2
2
  import { CommandContext } from 'evogram/lib/migrated';
3
3
  import { Client } from '../../Client';
4
- import { GetDepositOrderCommand } from './GetDepositOrder.command';
5
4
  import { formatMessage } from '../../utils/formatMessage';
5
+ import { GetDepositOrderCommand } from './GetDepositOrder.command';
6
+
7
+ // Функция для маскировки реквизитов: оставляет только последние 4 не пробельных символа
8
+ function maskExceptLast4(str: string): string {
9
+ if (!str) return '';
10
+
11
+ const chars = str.split('');
12
+ let nonSpaceCount = 0;
13
+ for (let i = chars.length - 1; i >= 0; i--) {
14
+ if (chars[i] !== ' ') {
15
+ nonSpaceCount++;
16
+ if (nonSpaceCount > 4) chars[i] = '*';
17
+ }
18
+ }
19
+ return chars.join('');
20
+ }
6
21
 
7
22
  @CommandD({ name: 'deposit', description: [{ text: 'Пополнение' }, { language: 'en', text: 'Deposit' }] })
8
23
  export class DepositCommand extends Command {
@@ -175,6 +190,10 @@ export class DepositCommand extends Command {
175
190
  parse_mode: 'HTML',
176
191
  });
177
192
  }, 1000);
193
+
194
+ setTimeout(() => {
195
+ clearInterval(interval);
196
+ }, 300_000);
178
197
  }
179
198
 
180
199
  const order = await config.API.post(`orders`, {
@@ -197,7 +216,7 @@ export class DepositCommand extends Command {
197
216
  {
198
217
  photo: config.images.deposit,
199
218
  header: '<b>❗️К сожалению, сейчас нет доступных реквизитов для оплаты.</b>',
200
- footer: '<i>ℹ️ Вы можете попробовать чуть позже, либо связаться с технической поддержкой.</i>',
219
+ footer: `<i>ℹ️ Вы можете попробовать чуть позже, воспользоваться другим способом оплаты, либо связаться с <a href="t.me/{{ ${config.support.username} }}">технической поддержкой</a>.</i>`,
201
220
  },
202
221
  {
203
222
  reply_markup: {
@@ -217,9 +236,15 @@ export class DepositCommand extends Command {
217
236
  to: 'RUB',
218
237
  ceiled: true,
219
238
  })})`
220
- : ''
239
+ : ``
221
240
  }`,
222
241
  {
242
+ // prettier-ignore
243
+ message:
244
+ order.card ?
245
+ `<b>💳 Реквизиты:</b> <code>${maskExceptLast4(order.card.requisites)}</code>\n` +
246
+ `<b>👩🏻‍💼 Получатель:</b> ${order.card.holder || '-'}`
247
+ : '',
223
248
  keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
224
249
  }
225
250
  );