nexushub-commands 1.3.3 → 1.4.0

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.
@@ -101,7 +101,7 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
101
101
  },
102
102
  });
103
103
  }
104
- if (!order.isRepeat)
104
+ if (!order.isRepeat) {
105
105
  yield context.user.log(0, `Запросил пополнение на ${Number(order.amount).toLocaleString('ru')} ${order.currency} ${order.currency !== 'RUB'
106
106
  ? `(${yield order.amount.convert({
107
107
  from: order.currency,
@@ -116,11 +116,35 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
116
116
  : '',
117
117
  keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
118
118
  });
119
- return context.redirect(GetDepositOrder_command_1.GetDepositOrderCommand, { orderId: order.id });
119
+ if (Number(deposit) !== Number(order.amount)) {
120
+ context.sendFormatted({
121
+ photo: config.images.deposit,
122
+ header: `<blockquote><b>ℹ️ Сумма пополнения стала выше</b></blockquote>\n\n<i>Для определения вашего пополнения в системе, Вам придется заплатить ${Number(order.amount).toLocaleString('ru')} ${order.currency.toUpperCase()}. Приносим свои извинения за неудобства</i>`,
123
+ }, {
124
+ reply_markup: {
125
+ inline_keyboard: [[{ text: '📖 Да, я все понял, продолжить', command: GetDepositOrder_command_1.GetDepositOrderCommand, payload: { orderId: order.id } }]],
126
+ },
127
+ });
128
+ }
129
+ }
130
+ setTimeout(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
131
+ var _a;
132
+ const neworder = yield config.API.get(`/orders/${order.id}`).then((x) => x.data);
133
+ if (['paid', 'fakepaid'].includes(neworder.status) || neworder.cheque)
134
+ return;
135
+ const msgInfo = yield context.client.database.config.get(`order${order.id}`);
136
+ if (!msgInfo)
137
+ return;
138
+ context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
139
+ context.sendFormatted({
140
+ 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>`,
141
+ });
142
+ }), new Date(order.expiresAt).getTime() - new Date().getTime());
143
+ context.redirect(GetDepositOrder_command_1.GetDepositOrderCommand, { orderId: order.id });
120
144
  }
121
145
  else {
122
146
  const wallets = (yield config.API.get('/crypto/wallets')).data.filter((x) => x.isActive);
123
- return context.sendFormatted({
147
+ context.sendFormatted({
124
148
  photo: config.images.depositCrypto,
125
149
  header: '<b>Создана заявка на оплату</b>',
126
150
  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.0",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -245,7 +245,7 @@ export class DepositCommand extends Command {
245
245
  );
246
246
  }
247
247
 
248
- if (!order.isRepeat)
248
+ if (!order.isRepeat) {
249
249
  await context.user.log(
250
250
  0,
251
251
  `Запросил пополнение на ${Number(order.amount).toLocaleString('ru')} ${order.currency} ${
@@ -268,11 +268,41 @@ export class DepositCommand extends Command {
268
268
  }
269
269
  );
270
270
 
271
- return context.redirect(GetDepositOrderCommand, { orderId: order.id });
271
+ if (Number(deposit) !== Number(order.amount)) {
272
+ context.sendFormatted(
273
+ {
274
+ photo: config.images.deposit,
275
+ header: `<blockquote><b>ℹ️ Сумма пополнения стала выше</b></blockquote>\n\n<i>Для определения вашего пополнения в системе, Вам придется заплатить ${Number(
276
+ order.amount
277
+ ).toLocaleString('ru')} ${order.currency.toUpperCase()}. Приносим свои извинения за неудобства</i>`,
278
+ },
279
+ {
280
+ reply_markup: {
281
+ inline_keyboard: [[{ text: '📖 Да, я все понял, продолжить', command: GetDepositOrderCommand, payload: { orderId: order.id } }]],
282
+ },
283
+ }
284
+ );
285
+ }
286
+ }
287
+
288
+ setTimeout(async () => {
289
+ const neworder = await config.API.get(`/orders/${order.id}`).then((x) => x.data);
290
+ if (['paid', 'fakepaid'].includes(neworder.status) || neworder.cheque) return;
291
+
292
+ const msgInfo = await context.client.database.config.get(`order${order.id}`);
293
+ if (!msgInfo) return;
294
+
295
+ context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
296
+ context.sendFormatted({
297
+ header: `<blockquote>⚠️ Время на оплату прошло</blockquote>\n\n<i>Мы не получили пополнение по нашим реквизитам. Они больше недоступны для пополнения</i>\n\n<b>ℹ️ Если Вы оплатили, а система не определила Ваш перевод - <a href="t.me/${context.mirror.projectMirror.design.supportBot?.username}">обратитесь в тех. поддержку</a></b>`,
298
+ });
299
+ }, new Date(order.expiresAt).getTime() - new Date().getTime());
300
+
301
+ context.redirect(GetDepositOrderCommand, { orderId: order.id });
272
302
  } else {
273
303
  const wallets = (await config.API.get('/crypto/wallets')).data.filter((x: any) => x.isActive);
274
304
 
275
- return context.sendFormatted({
305
+ context.sendFormatted({
276
306
  photo: config.images.depositCrypto,
277
307
  header: '<b>Создана заявка на оплату</b>',
278
308
  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
  }