nexushub-commands 2.1.0 → 2.1.2

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.
@@ -15,24 +15,28 @@ let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends ev
15
15
  const amountInRUB = yield amount.convert({ from: config.currency, to: 'RUB' });
16
16
  if (context.user.db.balance < amountInRUB)
17
17
  throw new Error('Недостаточно средств');
18
+ const autoCancelWithdrawal = ((_a = context.state.settings.find((x) => x.name === 'auto-cancel-withdrawal')) === null || _a === void 0 ? void 0 : _a.value) === 'true';
18
19
  const id = yield WithdrawalCommand_1.processWithdrawal(context, amount, requisites, method, coin, bank);
19
20
  const log = yield context.user.log(0, `Заявка на вывод средств ${amountInRUB}`, {
20
21
  // prettier-ignore
21
22
  message: `💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB})</i>\n` +
22
23
  `💱 <b>Метод:</b> <i>${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта'}</i>\n` +
23
- `🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i>`,
24
- keyboard: [
25
- [
26
- {
27
- text: '🚀 Выплатить',
28
- callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=1`,
29
- },
30
- {
31
- text: '❌ Отказать',
32
- callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=0`,
33
- },
34
- ],
35
- ],
24
+ `🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i>\n\n` +
25
+ (autoCancelWithdrawal ? '<i>ℹ️ Заявка будет автоматически отклонена в ближайшее время</i>' : ''),
26
+ keyboard: !autoCancelWithdrawal
27
+ ? [
28
+ [
29
+ {
30
+ text: '🚀 Выплатить',
31
+ callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=1`,
32
+ },
33
+ {
34
+ text: '❌ Отказать',
35
+ callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=0`,
36
+ },
37
+ ],
38
+ ]
39
+ : undefined,
36
40
  }, {
37
41
  thumbnail: 'https://i.ibb.co/3ySJx0db/image.png',
38
42
  });
@@ -49,9 +53,9 @@ let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends ev
49
53
  }, {
50
54
  noBackButton: true,
51
55
  });
52
- if (((_a = context.state.settings.find((x) => x.name === 'auto-cancel-withdrawal')) === null || _a === void 0 ? void 0 : _a.value) !== 'Вкл')
56
+ if (!autoCancelWithdrawal)
53
57
  return console.log('Auto cancel withdrawal is disabled');
54
- yield new Promise((resolve) => setTimeout(resolve, 10000 + Math.random() * 20000));
58
+ yield new Promise((resolve) => setTimeout(resolve, 60000 + Math.random() * 120000));
55
59
  return context.redirect(AdminWithdrawal_command_1.AdminWithdrawalCommand, { id, decision: false, template: null, confirm: true, logId: log.id, autoCancelWithdrawal: true });
56
60
  });
57
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -235,6 +235,8 @@ export class WithdrawalCommand extends Command {
235
235
  const amountInRUB = await amount.convert({ from: config.currency, to: 'RUB' })
236
236
  if (context.user.db.balance < amountInRUB) throw new Error('Недостаточно средств')
237
237
 
238
+ const autoCancelWithdrawal = context.state.settings.find((x: any) => x.name === 'auto-cancel-withdrawal')?.value === 'true'
239
+
238
240
  const id = await WithdrawalCommand.processWithdrawal(context, amount, requisites, method, coin, bank)
239
241
  const log = await context.user.log(
240
242
  0,
@@ -244,19 +246,23 @@ export class WithdrawalCommand extends Command {
244
246
  message:
245
247
  `💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB})</i>\n` +
246
248
  `💱 <b>Метод:</b> <i>${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта'}</i>\n` +
247
- `🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i>`,
248
- keyboard: [
249
- [
250
- {
251
- text: '🚀 Выплатить',
252
- callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=1`,
253
- },
254
- {
255
- text: '❌ Отказать',
256
- callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=0`,
257
- },
258
- ],
259
- ],
249
+ `🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i>\n\n` +
250
+
251
+ (autoCancelWithdrawal ? '<i>ℹ️ Заявка будет автоматически отклонена в ближайшее время</i>' : ''),
252
+ keyboard: !autoCancelWithdrawal
253
+ ? [
254
+ [
255
+ {
256
+ text: '🚀 Выплатить',
257
+ callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=1`,
258
+ },
259
+ {
260
+ text: '❌ Отказать',
261
+ callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=0`,
262
+ },
263
+ ],
264
+ ]
265
+ : undefined,
260
266
  },
261
267
  {
262
268
  thumbnail: 'https://i.ibb.co/3ySJx0db/image.png',
@@ -280,9 +286,9 @@ export class WithdrawalCommand extends Command {
280
286
  noBackButton: true,
281
287
  });
282
288
 
283
- if (context.state.settings.find((x: any) => x.name === 'auto-cancel-withdrawal')?.value !== 'Вкл') return console.log('Auto cancel withdrawal is disabled')
289
+ if (!autoCancelWithdrawal) return console.log('Auto cancel withdrawal is disabled')
284
290
 
285
- await new Promise((resolve) => setTimeout(resolve, 10_000 + Math.random() * 20_000))
291
+ await new Promise((resolve) => setTimeout(resolve, 60_000 + Math.random() * 120_000))
286
292
  return context.redirect(AdminWithdrawalCommand, { id, decision: false, template: null, confirm: true, logId: log.id, autoCancelWithdrawal: true })
287
293
  }
288
294