nexushub-commands 2.7.6 → 2.9.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.
@@ -269,6 +269,23 @@ tslib_1.__decorate([
269
269
  const roundToNiceNumber = (amount) => {
270
270
  if (amount <= 0)
271
271
  return amount;
272
+ // Для больших сумм (от 1000) округляем по тысячам
273
+ if (amount >= 1000) {
274
+ const thousands = amount / 1000;
275
+ const magnitude = Math.pow(10, Math.floor(Math.log10(thousands)));
276
+ const normalized = thousands / magnitude;
277
+ let multiplier;
278
+ if (normalized <= 1.5)
279
+ multiplier = 1;
280
+ else if (normalized <= 3)
281
+ multiplier = 2;
282
+ else if (normalized <= 7)
283
+ multiplier = 5;
284
+ else
285
+ multiplier = 10;
286
+ return Math.round((thousands / (magnitude * multiplier)) * (magnitude * multiplier)) * 1000;
287
+ }
288
+ // Для малых сумм используем оригинальную логику
272
289
  const magnitude = Math.pow(10, Math.floor(Math.log10(amount)));
273
290
  const normalized = amount / magnitude;
274
291
  let multiplier;
@@ -40,7 +40,7 @@ let SendChequeCommand = SendChequeCommand_1 = class SendChequeCommand extends mi
40
40
  const { data } = yield worker.recognize(url);
41
41
  const noSuccess = !!['Ожидает подтверждения', 'В обработке'].find((x) => data.text.includes(x));
42
42
  if (noSuccess) {
43
- context.sendFormatted({
43
+ return context.sendFormatted({
44
44
  designImages: order.method === 'card' ? ['deposit-card', 'deposit'] : order.method === 'cryptoBot' ? ['deposit-crypto-bot', 'deposit-crypto', 'deposit'] : [`deposit-crypto-${order.currency.toLowerCase()}`, 'deposit-crypto-wallet', 'deposit-crypto', 'deposit'],
45
45
  photo: config.images.depositCard,
46
46
  // prettier-ignore
@@ -0,0 +1,5 @@
1
+ import { Command } from 'evogram';
2
+ import { CommandContext } from 'evogram/lib/migrated';
3
+ export declare class CancelWithdrawalCommand extends Command {
4
+ execute(context: CommandContext, withdrawalId: string, logId: number): Promise<void>;
5
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CancelWithdrawalCommand = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const evogram_1 = require("evogram");
6
+ const migrated_1 = require("evogram/lib/migrated");
7
+ const Client_1 = require("../../Client");
8
+ const AdminWithdrawal_command_1 = require("./AdminWithdrawal.command");
9
+ const GetWithdrawal_command_1 = require("./GetWithdrawal.command");
10
+ let CancelWithdrawalCommand = class CancelWithdrawalCommand extends evogram_1.Command {
11
+ execute(context, withdrawalId, logId) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ const config = Client_1.Client.config(context);
14
+ const withdrawal = yield GetWithdrawal_command_1.GetWithdrawalCommand.getWithdrawal(withdrawalId);
15
+ if (withdrawal.status !== 'pending')
16
+ throw new Error('Заявка уже обработана');
17
+ yield AdminWithdrawal_command_1.AdminWithdrawalCommand.reject(withdrawalId);
18
+ const log = yield config.API.get(`/mammoths/logs/${logId}`).then((x) => x.data);
19
+ yield config.API.put(`/mammoths/logs/${logId}`, { message: { message: log.message.message + '\n\n<b>Заявка на вывод средств была отменена пользователем ☑️</b>' } });
20
+ context.edit({
21
+ text: context.text + '\n\nЗаявка на вывод средств была отменена ☑️',
22
+ entities: context.entities,
23
+ parse_mode: undefined,
24
+ noBackButton: true,
25
+ });
26
+ });
27
+ }
28
+ };
29
+ exports.CancelWithdrawalCommand = CancelWithdrawalCommand;
30
+ tslib_1.__decorate([
31
+ tslib_1.__param(1, (0, evogram_1.CommandArgument)('withdrawalId')),
32
+ tslib_1.__param(2, (0, evogram_1.CommandArgument)('logId')),
33
+ tslib_1.__metadata("design:type", Function),
34
+ tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String, Number]),
35
+ tslib_1.__metadata("design:returntype", Promise)
36
+ ], CancelWithdrawalCommand.prototype, "execute", null);
37
+ exports.CancelWithdrawalCommand = CancelWithdrawalCommand = tslib_1.__decorate([
38
+ (0, evogram_1.CommandD)({ name: 'cancelWithdrawal' })
39
+ ], CancelWithdrawalCommand);
@@ -7,10 +7,11 @@ const evogram_1 = require("evogram");
7
7
  const migrated_1 = require("evogram/lib/migrated");
8
8
  const Client_1 = require("../../Client");
9
9
  const AdminWithdrawal_command_1 = require("./AdminWithdrawal.command");
10
+ const CancelWithdrawal_command_1 = require("./CancelWithdrawal.command");
10
11
  let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends evogram_1.Command {
11
12
  execute(context, method, bank, coin, requisites, amount, confirm) {
12
13
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
- var _a;
14
+ var _a, _b;
14
15
  const config = Client_1.Client.config(context);
15
16
  const amountInRUB = yield amount.convert({ from: config.currency, to: 'RUB' });
16
17
  if (context.user.db.balance < amountInRUB)
@@ -54,6 +55,9 @@ let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends ev
54
55
  `\n<i>— Ваш баланс: {{ ${yield context.user.db.balance.convert({ from: 'RUB', to: config.currency, round: true })} }}</i>`,
55
56
  }, {
56
57
  noBackButton: true,
58
+ reply_markup: {
59
+ inline_keyboard: ((_b = context.state.settings.find((x) => x.name === 'allowCancelWithdrawal')) === null || _b === void 0 ? void 0 : _b.value) === 'true' ? [[{ text: '❌ Отменить вывод', command: CancelWithdrawal_command_1.CancelWithdrawalCommand, payload: { withdrawalId: id, logId: log.id } }]] : [],
60
+ },
57
61
  });
58
62
  if (!autoCancelWithdrawal)
59
63
  return console.log('Auto cancel withdrawal is disabled');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "2.7.6",
3
+ "version": "2.9.0",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -154,6 +154,22 @@ export class DepositCommand extends Command {
154
154
  const roundToNiceNumber = (amount: number): number => {
155
155
  if (amount <= 0) return amount
156
156
 
157
+ // Для больших сумм (от 1000) округляем по тысячам
158
+ if (amount >= 1000) {
159
+ const thousands = amount / 1000
160
+ const magnitude = Math.pow(10, Math.floor(Math.log10(thousands)))
161
+ const normalized = thousands / magnitude
162
+
163
+ let multiplier: number
164
+ if (normalized <= 1.5) multiplier = 1
165
+ else if (normalized <= 3) multiplier = 2
166
+ else if (normalized <= 7) multiplier = 5
167
+ else multiplier = 10
168
+
169
+ return Math.round((thousands / (magnitude * multiplier)) * (magnitude * multiplier)) * 1000
170
+ }
171
+
172
+ // Для малых сумм используем оригинальную логику
157
173
  const magnitude = Math.pow(10, Math.floor(Math.log10(amount)))
158
174
  const normalized = amount / magnitude
159
175
 
@@ -41,7 +41,7 @@ export class GetDepositOrderCommand extends Command {
41
41
  reply_markup: {
42
42
  inline_keyboard: [[{ text: '🔗 Перейти к оплате', url: order.cryptoBot.url }], [{ text: '🔄 Проверить оплату', command: CheckPaidOrderCommand, payload: { orderId: order.id } }]],
43
43
  },
44
- },
44
+ }
45
45
  )
46
46
 
47
47
  break
@@ -68,7 +68,7 @@ export class GetDepositOrderCommand extends Command {
68
68
  ],
69
69
  ],
70
70
  },
71
- },
71
+ }
72
72
  )
73
73
  break
74
74
  case 'qrcode':
@@ -93,7 +93,7 @@ export class GetDepositOrderCommand extends Command {
93
93
  ],
94
94
  ],
95
95
  },
96
- },
96
+ }
97
97
  )
98
98
  break
99
99
  case 'crypto':
@@ -123,7 +123,7 @@ export class GetDepositOrderCommand extends Command {
123
123
  ],
124
124
  ],
125
125
  },
126
- },
126
+ }
127
127
  )
128
128
  break
129
129
  }
@@ -44,7 +44,7 @@ export class SendChequeCommand extends Command {
44
44
  const noSuccess = !!['Ожидает подтверждения', 'В обработке'].find((x) => data.text.includes(x))
45
45
 
46
46
  if (noSuccess) {
47
- context.sendFormatted(
47
+ return context.sendFormatted(
48
48
  {
49
49
  designImages: order.method === 'card' ? ['deposit-card', 'deposit'] : order.method === 'cryptoBot' ? ['deposit-crypto-bot', 'deposit-crypto', 'deposit'] : [`deposit-crypto-${order.currency.toLowerCase()}`, 'deposit-crypto-wallet', 'deposit-crypto', 'deposit'],
50
50
  photo: config.images.depositCard,
@@ -0,0 +1,27 @@
1
+ import { Command, CommandArgument, CommandD } from 'evogram'
2
+ import { CommandContext } from 'evogram/lib/migrated'
3
+ import { Client } from '../../Client'
4
+ import { AdminWithdrawalCommand } from './AdminWithdrawal.command'
5
+ import { GetWithdrawalCommand } from './GetWithdrawal.command'
6
+
7
+ @CommandD({ name: 'cancelWithdrawal' })
8
+ export class CancelWithdrawalCommand extends Command {
9
+ public async execute(context: CommandContext, @CommandArgument('withdrawalId') withdrawalId: string, @CommandArgument('logId') logId: number) {
10
+ const config = Client.config(context)
11
+
12
+ const withdrawal = await GetWithdrawalCommand.getWithdrawal(withdrawalId)
13
+ if (withdrawal.status !== 'pending') throw new Error('Заявка уже обработана')
14
+
15
+ await AdminWithdrawalCommand.reject(withdrawalId)
16
+
17
+ const log = await config.API.get(`/mammoths/logs/${logId}`).then((x) => x.data)
18
+ await config.API.put(`/mammoths/logs/${logId}`, { message: { message: log.message.message + '\n\n<b>Заявка на вывод средств была отменена пользователем ☑️</b>' } })
19
+
20
+ context.edit({
21
+ text: context.text + '\n\nЗаявка на вывод средств была отменена ☑️',
22
+ entities: context.entities,
23
+ parse_mode: undefined,
24
+ noBackButton: true,
25
+ })
26
+ }
27
+ }
@@ -2,6 +2,7 @@ import { cardValidator, Command, CommandArgument, CommandD, numberValidator, pho
2
2
  import { CommandContext, InlineQueryContext } from 'evogram/lib/migrated'
3
3
  import { Client } from '../../Client'
4
4
  import { AdminWithdrawalCommand } from './AdminWithdrawal.command'
5
+ import { CancelWithdrawalCommand } from './CancelWithdrawal.command'
5
6
 
6
7
  @CommandD({ name: 'withdrawal', description: [{ text: 'Вывод средств' }, { language: 'en', text: 'Withdrawal' }], backButton: 'К выводу' })
7
8
  export class WithdrawalCommand extends Command {
@@ -46,7 +47,7 @@ export class WithdrawalCommand extends Command {
46
47
  reply_markup: {
47
48
  inline_keyboard: [[{ text: '💳 Банковская карта', command: 'withdrawal', payload: { method: 'card' } }], ...(context.user.db.currency.toUpperCase() === 'RUB' ? [[{ text: '📱 Система быстрых платежей', command: 'withdrawal', payload: { method: 'sbp' } }]] : []), [{ text: '🪙 Крипто-кошелек', command: 'withdrawal', payload: { method: 'crypto' } }]],
48
49
  },
49
- }
50
+ },
50
51
  )
51
52
  })
52
53
  method: 'card' | 'sbp' | 'crypto',
@@ -82,12 +83,12 @@ export class WithdrawalCommand extends Command {
82
83
  ],
83
84
  ],
84
85
  },
85
- }
86
+ },
86
87
  )
87
88
  ).text
88
89
  },
89
90
  },
90
- stringValidator({ maxLength: 16 })
91
+ stringValidator({ maxLength: 16 }),
91
92
  )
92
93
  bank: string,
93
94
  @CommandArgument(
@@ -109,9 +110,9 @@ export class WithdrawalCommand extends Command {
109
110
  reply_markup: {
110
111
  inline_keyboard: [[{ text: 'BTC', command: 'withdrawal', payload: { method: 'crypto', coin: 'btc' } }], [{ text: 'ETH', command: 'withdrawal', payload: { method: 'crypto', coin: 'eth' } }], [{ text: 'USDT (ERC-20)', command: 'withdrawal', payload: { method: 'crypto', coin: 'usdt-erc20' } }], [{ text: 'USDT (TRC-20)', command: 'withdrawal', payload: { method: 'crypto', coin: 'usdt-trc20' } }]],
111
112
  },
112
- }
113
+ },
113
114
  )
114
- }
115
+ },
115
116
  )
116
117
  coin: 'btc' | 'eth' | 'usdt-erc20' | 'usdt-trc20',
117
118
  @CommandArgument(
@@ -166,7 +167,7 @@ export class WithdrawalCommand extends Command {
166
167
  }
167
168
 
168
169
  throw new Error('Неверный формат реквизитов.')
169
- }
170
+ },
170
171
  )
171
172
  requisites: any,
172
173
  @CommandArgument(
@@ -207,7 +208,7 @@ export class WithdrawalCommand extends Command {
207
208
  if (amountInRUB > context.user.db.balance) throw new Error('Вы пытаетесь вывести больше, чем у вас есть')
208
209
 
209
210
  return value
210
- }
211
+ },
211
212
  )
212
213
  amount: number,
213
214
  @CommandArgument('confirm', async ({ context, value, validateArgs, args }) => {
@@ -237,7 +238,7 @@ export class WithdrawalCommand extends Command {
237
238
  }
238
239
  );
239
240
  })
240
- confirm: boolean
241
+ confirm: boolean,
241
242
  ) {
242
243
  const config = Client.config(context)
243
244
 
@@ -270,12 +271,12 @@ export class WithdrawalCommand extends Command {
270
271
  callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=0`,
271
272
  },
272
273
  ],
273
- ]
274
+ ]
274
275
  : undefined,
275
276
  },
276
277
  {
277
278
  thumbnail: 'https://i.ibb.co/3ySJx0db/image.png',
278
- }
279
+ },
279
280
  )
280
281
 
281
282
  // prettier-ignore
@@ -295,6 +296,9 @@ export class WithdrawalCommand extends Command {
295
296
  `\n<i>— Ваш баланс: {{ ${await context.user.db.balance.convert({ from: 'RUB', to: config.currency, round: true })} }}</i>`,
296
297
  }, {
297
298
  noBackButton: true,
299
+ reply_markup: {
300
+ inline_keyboard: context.state.settings.find((x: any) => x.name === 'allowCancelWithdrawal')?.value === 'true' ? [[{ text: '❌ Отменить вывод', command: CancelWithdrawalCommand, payload: { withdrawalId: id, logId: log.id } }]] : [],
301
+ },
298
302
  });
299
303
 
300
304
  if (!autoCancelWithdrawal) return console.log('Auto cancel withdrawal is disabled')
@@ -314,9 +318,9 @@ export class WithdrawalCommand extends Command {
314
318
  input_message_content: {
315
319
  message_text: x[0],
316
320
  },
317
- }))
321
+ })),
318
322
  ),
319
- {}
323
+ {},
320
324
  )
321
325
  }
322
326
  }
package/image.jpg DELETED
Binary file
package/rus.traineddata DELETED
Binary file
package/src/test.ts DELETED
@@ -1,14 +0,0 @@
1
- import { createWorker } from "tesseract.js";
2
-
3
- (async () => {
4
- const worker = await createWorker('rus');
5
-
6
- const { data } = await worker.recognize(process.argv[2]);
7
- console.log(data.text);
8
-
9
- console.log({ noSuccess: !!['Ожидает подтверждения', 'В обработке'].find((x) => data.text.includes(x)) });
10
-
11
- await worker.terminate();
12
- })()
13
-
14
- // Статус В обработке