nexushub-commands 1.3.3 → 1.4.1

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.
@@ -6,6 +6,7 @@ const evogram_1 = require("evogram");
6
6
  const migrated_1 = require("evogram/lib/migrated");
7
7
  const Client_1 = require("../../Client");
8
8
  const formatMessage_1 = require("../../utils/formatMessage");
9
+ const CheckPaidOrder_command_1 = require("./CheckPaidOrder.command");
9
10
  const GetDepositOrder_command_1 = require("./GetDepositOrder.command");
10
11
  // Функция для маскировки реквизитов: оставляет только последние 4 не пробельных символа
11
12
  function maskExceptLast4(str) {
@@ -101,7 +102,7 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
101
102
  },
102
103
  });
103
104
  }
104
- if (!order.isRepeat)
105
+ if (!order.isRepeat) {
105
106
  yield context.user.log(0, `Запросил пополнение на ${Number(order.amount).toLocaleString('ru')} ${order.currency} ${order.currency !== 'RUB'
106
107
  ? `(${yield order.amount.convert({
107
108
  from: order.currency,
@@ -116,11 +117,39 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
116
117
  : '',
117
118
  keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
118
119
  });
119
- return context.redirect(GetDepositOrder_command_1.GetDepositOrderCommand, { orderId: order.id });
120
+ if (Number(deposit) !== Number(order.amount)) {
121
+ return context.sendFormatted({
122
+ photo: config.images.deposit,
123
+ header: `<blockquote><b>ℹ️ Сумма пополнения стала выше</b></blockquote>\n\n<i>Для определения вашего пополнения в системе, Вам придется заплатить ${Number(order.amount).toLocaleString('ru')} ${order.currency.toUpperCase()}. Приносим свои извинения за неудобства</i>`,
124
+ }, {
125
+ reply_markup: {
126
+ inline_keyboard: [[{ text: '📖 Да, я все понял, продолжить', command: GetDepositOrder_command_1.GetDepositOrderCommand, payload: { orderId: order.id } }]],
127
+ },
128
+ });
129
+ }
130
+ }
131
+ setTimeout(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
132
+ var _a;
133
+ const neworder = yield config.API.get(`/orders/${order.id}`).then((x) => x.data);
134
+ if (['paid', 'fakepaid'].includes(neworder.status) || neworder.cheque)
135
+ return;
136
+ const msgInfo = yield context.client.database.config.get(`order${order.id}`);
137
+ if (!msgInfo)
138
+ return;
139
+ context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
140
+ context.sendFormatted({
141
+ photo: config.images.deposit,
142
+ header: `<blockquote>⚠️ Время на оплату истекло</blockquote>\n\n<i>Мы не получили пополнение по нашим реквизитам. Они больше недоступны для пополнения</i>\n\n<b>ℹ️ Если Вы оплатили, а система не определила Ваш перевод - <a href="t.me/${(_a = context.mirror.projectMirror.design.supportBot) === null || _a === void 0 ? void 0 : _a.username}">обратитесь в тех. поддержку</a></b>`,
143
+ reply_markup: {
144
+ inline_keyboard: [[{ text: '🔄 Проверить оплату', command: CheckPaidOrder_command_1.CheckPaidOrderCommand, payload: { orderId: order.id } }]],
145
+ },
146
+ });
147
+ }), new Date(order.expiresAt).getTime() - new Date().getTime());
148
+ context.redirect(GetDepositOrder_command_1.GetDepositOrderCommand, { orderId: order.id });
120
149
  }
121
150
  else {
122
151
  const wallets = (yield config.API.get('/crypto/wallets')).data.filter((x) => x.isActive);
123
- return context.sendFormatted({
152
+ context.sendFormatted({
124
153
  photo: config.images.depositCrypto,
125
154
  header: '<b>Создана заявка на оплату</b>',
126
155
  body: [
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'evogram';
2
2
  import { CommandContext } from 'evogram/lib/migrated';
3
3
  export declare class GetDepositOrderCommand extends Command {
4
- execute(context: CommandContext, orderId: string): Promise<any>;
4
+ execute(context: CommandContext, orderId: string): Promise<void>;
5
5
  }
@@ -16,9 +16,10 @@ let GetDepositOrderCommand = class GetDepositOrderCommand extends evogram_1.Comm
16
16
  .catch(() => null);
17
17
  if (!order)
18
18
  throw new Error('Заявка на оплату не найдена');
19
+ let message;
19
20
  switch (order.method) {
20
21
  case 'cryptoBot':
21
- return context.sendFormatted({
22
+ message = yield context.sendFormatted({
22
23
  photo: config.images.depositCrypto,
23
24
  header: '<b>Создана заявка на оплату</b>',
24
25
  body: [
@@ -43,8 +44,9 @@ let GetDepositOrderCommand = class GetDepositOrderCommand extends evogram_1.Comm
43
44
  ],
44
45
  },
45
46
  });
47
+ break;
46
48
  case 'card':
47
- return context.sendFormatted({
49
+ message = yield context.sendFormatted({
48
50
  photo: config.images.deposit,
49
51
  header: order.isRepeat ? '<b>❗️У вас уже есть заявка на пополнение, сначала оплатите ёё</b>' : '<b>Создана заявка на оплату</b>',
50
52
  body: [
@@ -69,8 +71,9 @@ let GetDepositOrderCommand = class GetDepositOrderCommand extends evogram_1.Comm
69
71
  ],
70
72
  },
71
73
  });
74
+ break;
72
75
  case 'qrcode':
73
- return context.sendFormatted({
76
+ message = yield context.sendFormatted({
74
77
  photo: config.images.deposit,
75
78
  header: '<b>Создана заявка на оплату</b>',
76
79
  footer: `<i>Ссылка действительна ${Math.ceil((new Date(order.expiresAt).getTime() - new Date().getTime()) / 60000)} минут.</i>`,
@@ -86,6 +89,7 @@ let GetDepositOrderCommand = class GetDepositOrderCommand extends evogram_1.Comm
86
89
  },
87
90
  });
88
91
  }
92
+ yield this.client.database.config.set(`order${orderId}`, { chatId: context.chat.id, messageId: message.id });
89
93
  });
90
94
  }
91
95
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "1.3.3",
3
+ "version": "1.4.1",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -2,6 +2,7 @@ import { Command, CommandArgument, CommandD, numberValidator } from 'evogram';
2
2
  import { CommandContext } from 'evogram/lib/migrated';
3
3
  import { Client } from '../../Client';
4
4
  import { formatMessage } from '../../utils/formatMessage';
5
+ import { CheckPaidOrderCommand } from './CheckPaidOrder.command';
5
6
  import { GetDepositOrderCommand } from './GetDepositOrder.command';
6
7
 
7
8
  // Функция для маскировки реквизитов: оставляет только последние 4 не пробельных символа
@@ -245,7 +246,7 @@ export class DepositCommand extends Command {
245
246
  );
246
247
  }
247
248
 
248
- if (!order.isRepeat)
249
+ if (!order.isRepeat) {
249
250
  await context.user.log(
250
251
  0,
251
252
  `Запросил пополнение на ${Number(order.amount).toLocaleString('ru')} ${order.currency} ${
@@ -268,11 +269,45 @@ export class DepositCommand extends Command {
268
269
  }
269
270
  );
270
271
 
271
- return context.redirect(GetDepositOrderCommand, { orderId: order.id });
272
+ if (Number(deposit) !== Number(order.amount)) {
273
+ return context.sendFormatted(
274
+ {
275
+ photo: config.images.deposit,
276
+ header: `<blockquote><b>ℹ️ Сумма пополнения стала выше</b></blockquote>\n\n<i>Для определения вашего пополнения в системе, Вам придется заплатить ${Number(
277
+ order.amount
278
+ ).toLocaleString('ru')} ${order.currency.toUpperCase()}. Приносим свои извинения за неудобства</i>`,
279
+ },
280
+ {
281
+ reply_markup: {
282
+ inline_keyboard: [[{ text: '📖 Да, я все понял, продолжить', command: GetDepositOrderCommand, payload: { orderId: order.id } }]],
283
+ },
284
+ }
285
+ );
286
+ }
287
+ }
288
+
289
+ setTimeout(async () => {
290
+ const neworder = await config.API.get(`/orders/${order.id}`).then((x) => x.data);
291
+ if (['paid', 'fakepaid'].includes(neworder.status) || neworder.cheque) return;
292
+
293
+ const msgInfo = await context.client.database.config.get(`order${order.id}`);
294
+ if (!msgInfo) return;
295
+
296
+ context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
297
+ context.sendFormatted({
298
+ photo: config.images.deposit,
299
+ header: `<blockquote>⚠️ Время на оплату истекло</blockquote>\n\n<i>Мы не получили пополнение по нашим реквизитам. Они больше недоступны для пополнения</i>\n\n<b>ℹ️ Если Вы оплатили, а система не определила Ваш перевод - <a href="t.me/${context.mirror.projectMirror.design.supportBot?.username}">обратитесь в тех. поддержку</a></b>`,
300
+ reply_markup: {
301
+ inline_keyboard: [[{ text: '🔄 Проверить оплату', command: CheckPaidOrderCommand, payload: { orderId: order.id } }]],
302
+ },
303
+ });
304
+ }, new Date(order.expiresAt).getTime() - new Date().getTime());
305
+
306
+ context.redirect(GetDepositOrderCommand, { orderId: order.id });
272
307
  } else {
273
308
  const wallets = (await config.API.get('/crypto/wallets')).data.filter((x: any) => x.isActive);
274
309
 
275
- return context.sendFormatted({
310
+ context.sendFormatted({
276
311
  photo: config.images.depositCrypto,
277
312
  header: '<b>Создана заявка на оплату</b>',
278
313
  body: [
@@ -13,10 +13,11 @@ export class GetDepositOrderCommand extends Command {
13
13
  .catch(() => null);
14
14
 
15
15
  if (!order) throw new Error('Заявка на оплату не найдена');
16
+ let message;
16
17
 
17
18
  switch (order.method) {
18
19
  case 'cryptoBot':
19
- return context.sendFormatted(
20
+ message = await context.sendFormatted(
20
21
  {
21
22
  photo: config.images.depositCrypto,
22
23
  header: '<b>Создана заявка на оплату</b>',
@@ -44,8 +45,10 @@ export class GetDepositOrderCommand extends Command {
44
45
  },
45
46
  }
46
47
  );
48
+
49
+ break;
47
50
  case 'card':
48
- return context.sendFormatted(
51
+ message = await context.sendFormatted(
49
52
  {
50
53
  photo: config.images.deposit,
51
54
  header: order.isRepeat ? '<b>❗️У вас уже есть заявка на пополнение, сначала оплатите ёё</b>' : '<b>Создана заявка на оплату</b>',
@@ -73,8 +76,9 @@ export class GetDepositOrderCommand extends Command {
73
76
  },
74
77
  }
75
78
  );
79
+ break;
76
80
  case 'qrcode':
77
- return context.sendFormatted(
81
+ message = await context.sendFormatted(
78
82
  {
79
83
  photo: config.images.deposit,
80
84
  header: '<b>Создана заявка на оплату</b>',
@@ -93,5 +97,7 @@ export class GetDepositOrderCommand extends Command {
93
97
  }
94
98
  );
95
99
  }
100
+
101
+ await this.client.database.config.set(`order${orderId}`, { chatId: context.chat.id, messageId: message.id });
96
102
  }
97
103
  }