nexushub-commands 1.6.7 → 1.8.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.
package/lib/Client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
+ import { Evogram } from 'evogram';
2
3
  import { CommandContext } from 'evogram/lib/migrated';
3
4
  export interface DepositConfig {
4
5
  API: AxiosInstance;
@@ -7,6 +8,9 @@ export interface DepositConfig {
7
8
  deposit: string;
8
9
  depositCard: string;
9
10
  depositCrypto: string;
11
+ withdrawal: string;
12
+ withdrawalCard: string;
13
+ withdrawalCrypto: string;
10
14
  [key: string]: string;
11
15
  };
12
16
  support: {
@@ -14,6 +18,7 @@ export interface DepositConfig {
14
18
  };
15
19
  agreement: string;
16
20
  menuCommand: any;
21
+ getClient: (token: string) => Promise<Evogram>;
17
22
  }
18
23
  export declare class Client {
19
24
  static config: (context: CommandContext) => DepositConfig;
package/lib/Client.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Client = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const evogram_1 = require("evogram");
6
7
  // Значения по умолчанию для конфигурации
7
8
  const defaultConfig = {
8
9
  API: axios_1.default.create(),
@@ -11,12 +12,16 @@ const defaultConfig = {
11
12
  deposit: 'deposit',
12
13
  depositCard: 'deposit-card',
13
14
  depositCrypto: 'deposit-crypto',
15
+ withdrawal: 'withdrawal',
16
+ withdrawalCard: 'withdrawal-card',
17
+ withdrawalCrypto: 'withdrawal-crypto',
14
18
  },
15
19
  support: {
16
20
  username: 'support',
17
21
  },
18
22
  agreement: 'https://telegra.ph/User-Agreement-02-07-17',
19
23
  menuCommand: null,
24
+ getClient: (token) => Promise.resolve(new evogram_1.Evogram({ token })),
20
25
  };
21
26
  class Client {
22
27
  }
@@ -1,2 +1,3 @@
1
1
  export * from './deposit';
2
2
  export * from './registration';
3
+ export * from './withdrawal';
@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./deposit"), exports);
5
5
  tslib_1.__exportStar(require("./registration"), exports);
6
+ tslib_1.__exportStar(require("./withdrawal"), exports);
@@ -0,0 +1,14 @@
1
+ import { Command } from 'evogram';
2
+ import { CommandContext } from 'evogram/lib/migrated';
3
+ import { DepositConfig } from '../../Client';
4
+ export declare class AdminWithdrawalCommand extends Command {
5
+ static approve(id: string): Promise<void>;
6
+ static reject(id: string): Promise<void>;
7
+ static getRejectedMessages(config: DepositConfig): {
8
+ title: string;
9
+ text: string;
10
+ photo?: string;
11
+ }[];
12
+ static logMessages: Record<number, CommandContext>;
13
+ execute(context: CommandContext, id: string, decision: boolean, template: number, confirm: boolean): Promise<any>;
14
+ }
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var AdminWithdrawalCommand_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AdminWithdrawalCommand = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const evogram_1 = require("evogram");
7
+ const migrated_1 = require("evogram/lib/migrated");
8
+ const Client_1 = require("../../Client");
9
+ const GetWithdrawal_command_1 = require("./GetWithdrawal.command");
10
+ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCommand extends evogram_1.Command {
11
+ static approve(id) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () { });
13
+ }
14
+ static reject(id) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () { });
16
+ }
17
+ static getRejectedMessages(config) {
18
+ return [
19
+ {
20
+ title: '⚠️ Ошибка вывода средств',
21
+ text: `При обработке вашего запроса на вывод средств произошла непредвиденная ошибка. Это может быть связано с техническими неполадками на стороне платежной системы, временными ограничениями вашего банка или некорректными данными.\n\nДля решения проблемы, пожалуйста, обратитесь в службу <a href="https://t.me/${config.support.username}">технической поддержки</a>`,
22
+ photo: config.images.withdrawal,
23
+ },
24
+ {
25
+ title: '❄️ Временная блокировка',
26
+ text: `Ваш аккаунт временно ограничен для проведения финансовых операций. Это может быть связано с:\n\n<i>— Подозрением на нарушение правил платформы;</i>\n<i>— Попыткой несанкционированного доступа;</i>\n<i>— Необходимостью дополнительной проверки личности.</i>\n\nДля разблокировки, пожалуйста, обратитесь в <a href="https://t.me/${config.support.username}">службу технической поддержки</a>`,
27
+ },
28
+ {
29
+ title: '🔄 Требуется верификация',
30
+ text: 'Наша система безопасности обнаружила необычные действия в вашем аккаунте. Чтобы исключить мошенничество, пожалуйста, подтвердите свою личность, напишите в техническую поддержку «Верификация». После завершения проверки вывод средств будет автоматически разблокирован.',
31
+ },
32
+ {
33
+ title: '🚫 Превышен лимит заявок',
34
+ text: `Система заблокировала новые заявки на вывод из-за слишком частых запросов. Такое может произойти при многократных попытках отправить одну и ту же сумму или технических ошибках. Пожалуйста, повторите попытку позже или <a href="https://t.me/${config.support.username}">свяжитесь с нами</a> для ручной проверки.`,
35
+ },
36
+ {
37
+ title: '🔒 Подтверждение реквизитов',
38
+ text: `В целях безопасности вывод средств разрешен только после подтверждения ваших реквизитов. Для этого необходимо совершить пополнение счета с того же платежного метода, который вы указали для вывода. Это разовая процедура, которая помогает нам убедиться, что вы являетесь владельцем указанных реквизитов.\n\nЕсли у вас возникли сложности — обратитесь в <a href="https://t.me/${config.support.username}">тех. поддержку</a>`,
39
+ },
40
+ ];
41
+ }
42
+ execute(context, id, decision, template, confirm) {
43
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
44
+ var _a, _b;
45
+ if (!AdminWithdrawalCommand_1.logMessages[id])
46
+ AdminWithdrawalCommand_1.logMessages[id] = context;
47
+ const withdrawal = yield GetWithdrawal_command_1.GetWithdrawalCommand.getWithdrawal(id);
48
+ const withdrawalFormattedID = Math.floor(Math.random() * 500000000 + 500000000)
49
+ .toString(36)
50
+ .toUpperCase();
51
+ const config = Client_1.Client.config(context);
52
+ const mammoth = yield config.API.get(`/projects/mammoths/${withdrawal.user}`).then((x) => x.data);
53
+ console.log(mammoth.mirror);
54
+ const client = yield config.getClient(mammoth.mirror.mirror.token);
55
+ if (decision) {
56
+ yield AdminWithdrawalCommand_1.approve(withdrawal.id);
57
+ // prettier-ignore
58
+ client.api.sendPhoto({
59
+ chat_id: withdrawal.user,
60
+ photo: config.images.withdrawal,
61
+ caption: `<blockquote><b>💸 Одобрена заявка на вывод средств #{{ ${withdrawalFormattedID} }}</b></blockquote>\n\n` +
62
+ `<i>— Сумма: {{ ${withdrawal.amount.toLocaleString('ru')} ${config.currency.toUpperCase()} }}</i>\n` +
63
+ `<i>— Метод: {{ ${withdrawal.method === 'crypto' ? `Крипто-кошелек ${(_a = withdrawal.coin) === null || _a === void 0 ? void 0 : _a.toUpperCase()}` : withdrawal.method === 'sbp' ? 'Номер телефона' : 'Банковская карта'} }}</i>\n` +
64
+ `<i>— Реквизиты: {{ ${withdrawal.requisites} }}</i>\n` +
65
+ `<i>— Дата: {{ ${withdrawal.date.toLocaleString('ru')} }}</i>\n\n` +
66
+ '<b>ℹ️ Средства поступят на ваши реквизиты в течении ближайшего времени.</b>',
67
+ parse_mode: 'HTML',
68
+ });
69
+ }
70
+ else {
71
+ if (template === undefined) {
72
+ return context.sendFormatted({
73
+ noPhoto: true,
74
+ header: `<blockquote><b>❌ Отклонена заявка на вывод средств</b></blockquote>\n\n<i>Выберите причину отклонения вывода или пропустите этот этап.</i>`,
75
+ }, {
76
+ reply_markup: {
77
+ inline_keyboard: [
78
+ ...AdminWithdrawalCommand_1.getRejectedMessages(config).map((x, i) => [
79
+ {
80
+ text: x.title,
81
+ command: AdminWithdrawalCommand_1,
82
+ payload: {
83
+ id,
84
+ decision: false,
85
+ template: i,
86
+ },
87
+ },
88
+ ]),
89
+ [{ text: 'Пропустить этап', command: AdminWithdrawalCommand_1, payload: { id, decision: false, template: null, confirm: true } }],
90
+ ],
91
+ },
92
+ });
93
+ }
94
+ if (!confirm) {
95
+ return context.sendFormatted({
96
+ noPhoto: true,
97
+ header: `<blockquote><b>${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].text}`,
98
+ }, {
99
+ reply_markup: {
100
+ inline_keyboard: [
101
+ [
102
+ { text: '‹ Назад', command: AdminWithdrawalCommand_1, payload: { id, decision, template: undefined } },
103
+ { text: 'Продолжить ›', command: AdminWithdrawalCommand_1, payload: { id, decision, template, confirm: true } },
104
+ ],
105
+ ],
106
+ },
107
+ });
108
+ }
109
+ yield AdminWithdrawalCommand_1.reject(id);
110
+ // prettier-ignore
111
+ const msg = yield client.api.sendPhoto({
112
+ chat_id: withdrawal.user,
113
+ photo: config.images.withdrawal,
114
+ caption: `<blockquote><b>❌ Отклонена заявка на вывод средств</b></blockquote>\n\n` +
115
+ `<i>— Сумма: {{ ${withdrawal.amount.toLocaleString('ru')} ${config.currency.toUpperCase()} }}</i>\n` +
116
+ `<i>— Метод: {{ ${withdrawal.method === 'crypto' ? `Крипто-кошелек ${(_b = withdrawal.coin) === null || _b === void 0 ? void 0 : _b.toUpperCase()}` : withdrawal.method === 'sbp' ? 'Номер телефона' : 'Банковская карта'} }}</i>\n` +
117
+ `<i>— Реквизиты: {{ ${withdrawal.requisites} }}</i>\n` +
118
+ (template === null ? `\n<b>ℹ️ Обратитесь в <a href="https://t.me/${config.support.username}">тех. поддержку</a> для уточнения проблемы.</b>` : ''),
119
+ reply_markup: template === null ? { inline_keyboard: [[{ text: '👨‍💻 Тех. поддержка', url: `https://t.me/${config.support.username}` }]] } : undefined,
120
+ parse_mode: 'HTML',
121
+ });
122
+ if (template !== null) {
123
+ msg.reply(`<blockquote>${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].title}</blockquote>\n\n${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].text}`, {
124
+ parse_mode: 'HTML',
125
+ reply_markup: { inline_keyboard: [[{ text: '👨‍💻 Тех. поддержка', url: `https://t.me/${config.support.username}` }]] },
126
+ });
127
+ }
128
+ context = AdminWithdrawalCommand_1.logMessages[withdrawal.id] || context;
129
+ context.sendFormatted({
130
+ noPhoto: true,
131
+ edit: true,
132
+ }, {
133
+ parse_mode: undefined,
134
+ text: context.text + (decision ? '\n\nЗаявка на вывод средств была успешно обработана ☑️' : '\n\nЗаявка на вывод средств была успешно отклонена ☑️'),
135
+ entities: context.entities,
136
+ });
137
+ }
138
+ });
139
+ }
140
+ };
141
+ exports.AdminWithdrawalCommand = AdminWithdrawalCommand;
142
+ AdminWithdrawalCommand.logMessages = {};
143
+ tslib_1.__decorate([
144
+ tslib_1.__param(1, (0, evogram_1.CommandArgument)('id')),
145
+ tslib_1.__param(2, (0, evogram_1.CommandArgument)('decision', ({ value }) => value === '1')),
146
+ tslib_1.__param(3, (0, evogram_1.CommandArgument)('template?')),
147
+ tslib_1.__param(4, (0, evogram_1.CommandArgument)('confirm?')),
148
+ tslib_1.__metadata("design:type", Function),
149
+ tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String, Boolean, Number, Boolean]),
150
+ tslib_1.__metadata("design:returntype", Promise)
151
+ ], AdminWithdrawalCommand.prototype, "execute", null);
152
+ exports.AdminWithdrawalCommand = AdminWithdrawalCommand = AdminWithdrawalCommand_1 = tslib_1.__decorate([
153
+ (0, evogram_1.CommandD)({ name: 'ewithdrawal' })
154
+ ], AdminWithdrawalCommand);
@@ -0,0 +1,15 @@
1
+ import { Command, CommandContext } from 'evogram';
2
+ export declare class GetWithdrawalCommand extends Command {
3
+ static getWithdrawal(id: string): Promise<{
4
+ id: string;
5
+ user: number;
6
+ amount: number;
7
+ date: Date;
8
+ method: string;
9
+ requisites: string;
10
+ coin?: string;
11
+ bank?: string;
12
+ status: 'pending' | 'approved' | 'rejected';
13
+ }>;
14
+ execute(context: CommandContext, withdrawalId: string): Promise<void>;
15
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var GetWithdrawalCommand_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.GetWithdrawalCommand = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const evogram_1 = require("evogram");
7
+ let GetWithdrawalCommand = GetWithdrawalCommand_1 = class GetWithdrawalCommand extends evogram_1.Command {
8
+ static getWithdrawal(id) {
9
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
+ return {
11
+ id: '1',
12
+ user: 1,
13
+ amount: 100,
14
+ date: new Date(),
15
+ method: 'card',
16
+ requisites: '1234567890',
17
+ coin: 'BTC',
18
+ bank: 'Tinkoff',
19
+ status: 'pending',
20
+ };
21
+ });
22
+ }
23
+ execute(context, withdrawalId) {
24
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
+ const withdrawal = yield GetWithdrawalCommand_1.getWithdrawal(withdrawalId);
26
+ });
27
+ }
28
+ };
29
+ exports.GetWithdrawalCommand = GetWithdrawalCommand;
30
+ tslib_1.__decorate([
31
+ tslib_1.__param(1, (0, evogram_1.CommandArgument)('withdrawalId')),
32
+ tslib_1.__metadata("design:type", Function),
33
+ tslib_1.__metadata("design:paramtypes", [evogram_1.CommandContext, String]),
34
+ tslib_1.__metadata("design:returntype", Promise)
35
+ ], GetWithdrawalCommand.prototype, "execute", null);
36
+ exports.GetWithdrawalCommand = GetWithdrawalCommand = GetWithdrawalCommand_1 = tslib_1.__decorate([
37
+ (0, evogram_1.CommandD)({ name: 'getwithdrawal' })
38
+ ], GetWithdrawalCommand);
@@ -0,0 +1,4 @@
1
+ import { Command, CommandContext } from 'evogram';
2
+ export declare class SendWithdrawalErrorCommand extends Command {
3
+ execute(context: CommandContext, withdrawalId: string, template: number): Promise<void>;
4
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SendWithdrawalErrorCommand = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const evogram_1 = require("evogram");
6
+ const Client_1 = require("../../Client");
7
+ const AdminWithdrawal_command_1 = require("./AdminWithdrawal.command");
8
+ const GetWithdrawal_command_1 = require("./GetWithdrawal.command");
9
+ let SendWithdrawalErrorCommand = class SendWithdrawalErrorCommand extends evogram_1.Command {
10
+ execute(context, withdrawalId, template) {
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ const withdrawal = yield GetWithdrawal_command_1.GetWithdrawalCommand.getWithdrawal(withdrawalId);
13
+ const config = Client_1.Client.config(context);
14
+ const [text, photo, params] = (yield AdminWithdrawal_command_1.AdminWithdrawalCommand.getRejectedMessages())[template];
15
+ });
16
+ }
17
+ };
18
+ exports.SendWithdrawalErrorCommand = SendWithdrawalErrorCommand;
19
+ tslib_1.__decorate([
20
+ tslib_1.__param(1, (0, evogram_1.CommandArgument)('withdrawalId')),
21
+ tslib_1.__param(2, (0, evogram_1.CommandArgument)('template')),
22
+ tslib_1.__metadata("design:type", Function),
23
+ tslib_1.__metadata("design:paramtypes", [evogram_1.CommandContext, String, Number]),
24
+ tslib_1.__metadata("design:returntype", Promise)
25
+ ], SendWithdrawalErrorCommand.prototype, "execute", null);
26
+ exports.SendWithdrawalErrorCommand = SendWithdrawalErrorCommand = tslib_1.__decorate([
27
+ (0, evogram_1.CommandD)({ name: 'sendwithdrawalerror' })
28
+ ], SendWithdrawalErrorCommand);
@@ -0,0 +1,8 @@
1
+ import { Command } from 'evogram';
2
+ import { CommandContext, InlineQueryContext } from 'evogram/lib/migrated';
3
+ export declare class WithdrawalCommand extends Command {
4
+ static processWithdrawal: (context: CommandContext, amount: number, requisites: any, method: string, coin?: string, bank?: string) => Promise<never>;
5
+ static BANKS: string[][];
6
+ execute(context: CommandContext, method: 'card' | 'sbp' | 'crypto', bank: string, coin: 'btc' | 'eth' | 'usdt-erc20' | 'usdt-trc20', requisites: any, amount: number, confirm: boolean): Promise<void>;
7
+ inlineExecute(context: InlineQueryContext): Promise<void>;
8
+ }
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ var WithdrawalCommand_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.WithdrawalCommand = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const evogram_1 = require("evogram");
7
+ const migrated_1 = require("evogram/lib/migrated");
8
+ const Client_1 = require("../../Client");
9
+ const AdminWithdrawal_command_1 = require("./AdminWithdrawal.command");
10
+ let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends evogram_1.Command {
11
+ execute(context, method, bank, coin, requisites, amount, confirm) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ const config = Client_1.Client.config(context);
14
+ const amountInRUB = yield amount.convert({ from: config.currency, to: 'RUB' });
15
+ if (context.user.db.balance < amountInRUB)
16
+ throw new Error('Недостаточно средств');
17
+ const id = yield WithdrawalCommand_1.processWithdrawal(context, amount, requisites, method, coin, bank);
18
+ // context.user.db.balance -= amountInRUB;
19
+ // await context.user.db.save();
20
+ // const withdrawal = await DatabaseManager.getInstance()
21
+ // .dataSource.getRepository(Withdrawals)
22
+ // .save({
23
+ // amount: Number(amount),
24
+ // method,
25
+ // coin: method === 'crypto' ? coin : undefined,
26
+ // requisites: method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted,
27
+ // user: context.user.db,
28
+ // });
29
+ // const _method = method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта';
30
+ // context.user.db.requisites = `${withdrawal.requisites} [${_method}${method === 'sbp' ? ` [${bank}]` : ''}]`;
31
+ console.log({
32
+ text: '🚀 Выплатить',
33
+ callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=1`,
34
+ }, {
35
+ text: '❌ Отказать',
36
+ callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=0`,
37
+ });
38
+ context.user.log(0, `Заявка на вывод средств ${amountInRUB}`, {
39
+ // prettier-ignore
40
+ message: `💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB})</i>\n` +
41
+ `💱 <b>Метод:</b> <i>${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта'}</i>\n` +
42
+ `🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i>`,
43
+ keyboard: [
44
+ [
45
+ {
46
+ text: '🚀 Выплатить',
47
+ callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=1`,
48
+ },
49
+ {
50
+ text: '❌ Отказать',
51
+ callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=0`,
52
+ },
53
+ ],
54
+ ],
55
+ });
56
+ // prettier-ignore
57
+ context.sendFormatted({
58
+ photo: method === 'crypto' ? config.images.withdrawalCrypto : config.images.withdrawal,
59
+ header: '<blockquote><b>💸 Создана заявка на вывод средств</b></blockquote>\n\n' +
60
+ `<i>— Сумма: {{ ${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} }}</i>\n` +
61
+ `<i>— Реквизиты: {{ ${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted} }}</i>\n` +
62
+ `<i>— Метод: {{ ${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : requisites.card ? 'Банковская карта' : 'Номер телефона'} }}</i>\n` +
63
+ `<i>— Дата: {{ ${new Date().toLocaleString('ru')} }}</i>\n` +
64
+ (method === 'sbp' ? `<i>— Банк: {{ ${bank} }}</i>\n` : '') +
65
+ `\n<i>— Ваш баланс: {{ ${yield context.user.db.balance.convert({ from: 'RUB', to: config.currency, round: true })} }}</i>`,
66
+ }, {
67
+ noBackButton: true,
68
+ });
69
+ });
70
+ }
71
+ inlineExecute(context) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
+ context.answer(yield Promise.all(WithdrawalCommand_1.BANKS.map((x) => tslib_1.__awaiter(this, void 0, void 0, function* () {
74
+ return ({
75
+ type: 'article',
76
+ id: x[0],
77
+ title: x[0],
78
+ thumb_url: x[1] || 'https://s0.rbk.ru/v6_top_pics/media/img/6/03/754598843127036.jpeg',
79
+ input_message_content: {
80
+ message_text: x[0],
81
+ },
82
+ });
83
+ }))), {});
84
+ });
85
+ }
86
+ };
87
+ exports.WithdrawalCommand = WithdrawalCommand;
88
+ WithdrawalCommand.processWithdrawal = (context, amount, requisites, method, coin, bank) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
89
+ throw new Error('Not implemented');
90
+ });
91
+ WithdrawalCommand.BANKS = [
92
+ [
93
+ 'Тинькофф',
94
+ 'https://sun1-92.userapi.com/s/v1/ig2/EfdDUJFU4m19qq8PEU-naHEIdUglx65FzbNd2Z0rDfj5DCRUuPU9ky7bOGTY_y9hZR0bYvFFCdsnKOXgqEF5i7Pv.jpg?size=1080x1080&quality=95&crop=0,0,1080,1080&ava=1',
95
+ ],
96
+ ['Сбербанк', 'https://avatars.mds.yandex.net/get-altay/11047345/2a0000018d3fb02e7d90805b68eb881f54f2/diploma'],
97
+ ['Альфа-Банк', 'https://cc.guru/uploads/cca2025/thumb-36_12400_image_7232d25eff1891395d0505dfa93a2b26.jpg?1733242515'],
98
+ ['ВТБ', 'https://tc-maxima.ru/wp-content/uploads/2023/11/bazgazbzsfbawjmcmi7gmsrm4zir48_fq7wec-vqq_zqkj21r8cxfd3i-mfdhxebpqsrcgv2exup3veozmb56z33.jpg'],
99
+ ['Россельхозбанк', 'https://дворецкультуры.онлайн/upload/iblock/f44/f4441dc07f96bc108e43e4c859ec45b3.jpg'],
100
+ ['Райффайзенбанк', 'https://avatars.mds.yandex.net/i?id=61b52fabb12237bb017c4360112d14ac_l-5241671-images-thumbs&n=13'],
101
+ ['Русский Стандарт', 'https://lh3.googleusercontent.com/ACplx3IdF_Jq0h46AZRm8KIzBm1DkTwNfirSzhg1KPkBbGmH0TOobQO7zo85SXfVPQ'],
102
+ ['Промсвязьбанк', 'https://s3-figma-hubfile-images-production.figma.com/hub/file/carousel/img/0e5feb3fe24f75bcd08ef0e40da4c7fa7c207997'],
103
+ ['Газпромбанк', 'https://pic.rutubelist.ru/user/95/76/9576f91d2353ad868a0e365994e14ade.jpg'],
104
+ ['Банк Открытие', 'https://freesoft.ru/storage/images/704/7040/703927/703927_normal.png'],
105
+ ['Хоум Банк', 'http://brobank.ru/wp-content/uploads/2023/04/homebank-logo-icon.png'],
106
+ ['ОТП Банк', 'https://habrastorage.org/getpro/moikrug/uploads/company/996/859/586/logo/big_78497ffc0d25d89cc4af847b9c7a353b.png'],
107
+ [
108
+ 'Уралсиб',
109
+ 'https://static.rustore.ru/imgproxy/ygBp-kTr7gSoYBqCrb3xJ1GIXxMaE3q08ANNb_emdBA/preset:app_card_icon/aHR0cHM6Ly9zdGF0aWMucnVzdG9yZS5ydS9hcGsvMTY5MzkxODY1NS9jb250ZW50L0lDT04vNjVlZWU5NDAtOTQ1Zi00MzJhLWE2OWYtOWQyZTYyNzcxZjIwLnBuZw==.webp',
110
+ ],
111
+ [
112
+ 'Ozon Банк',
113
+ 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f2/%D0%9B%D0%BE%D0%B3%D0%BE%D1%82%D0%B8%D0%BF_Ozon_%D0%B1%D0%B0%D0%BD%D0%BA.jpg/1200px-%D0%9B%D0%BE%D0%B3%D0%BE%D1%82%D0%B8%D0%BF_Ozon_%D0%B1%D0%B0%D0%BD%D0%BA.jpg',
114
+ ],
115
+ ['МТС Банк', 'https://static.mts.ru/mts_rf/images/logo/new/mts_logo_cmyk.png'],
116
+ ['Почта Банк', 'https://berezovskoe-r04.gosweb.gosuslugi.ru/netcat_files/37/45/850original_06ecae.jpg'],
117
+ ['ЮMoney', 'https://bankinform.ru/images/logo/logo2/yandexpay.png?width=250'],
118
+ ];
119
+ tslib_1.__decorate([
120
+ tslib_1.__param(1, (0, evogram_1.CommandArgument)('method', (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ context, value }) {
121
+ if (value)
122
+ return value;
123
+ const config = Client_1.Client.config(context);
124
+ yield context.sendFormatted({
125
+ photo: config.images.withdrawal,
126
+ header: '<b>📤 Выберите удобный для вас метод вывода.</b>',
127
+ }, {
128
+ reply_markup: {
129
+ inline_keyboard: [
130
+ [{ text: '💳 Банковская карта', command: 'withdrawal', payload: { method: 'card' } }],
131
+ ...(context.user.db.currency.toUpperCase() === 'RUB'
132
+ ? [[{ text: '📱 Система быстрых платежей', command: 'withdrawal', payload: { method: 'sbp' } }]]
133
+ : []),
134
+ [{ text: '🪙 Крипто-кошелек', command: 'withdrawal', payload: { method: 'crypto' } }],
135
+ ],
136
+ },
137
+ });
138
+ }))),
139
+ tslib_1.__param(2, (0, evogram_1.CommandArgument)({
140
+ name: 'bank',
141
+ question: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ context, args, error }) {
142
+ if (args.method !== 'sbp')
143
+ return 'none';
144
+ const config = Client_1.Client.config(context);
145
+ return (yield context.sendFormattedQuestion({
146
+ photo: config.images.withdrawal,
147
+ body: [
148
+ {
149
+ title: '💳 Банк для вывода',
150
+ data: [['Выберите банк для вывода или напишите свой']],
151
+ },
152
+ ],
153
+ error: error === null || error === void 0 ? void 0 : error.message,
154
+ }, {
155
+ reply_markup: {
156
+ inline_keyboard: [
157
+ [
158
+ {
159
+ text: '🏦 Выбрать банк',
160
+ command: WithdrawalCommand,
161
+ switch_inline_query_current_chat: ' ',
162
+ },
163
+ ],
164
+ ],
165
+ },
166
+ })).text;
167
+ }),
168
+ }, (0, evogram_1.stringValidator)({ maxLength: 16 }))),
169
+ tslib_1.__param(3, (0, evogram_1.CommandArgument)({
170
+ name: 'coin',
171
+ }, (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ context, value, args }) {
172
+ if (value)
173
+ return value;
174
+ else if (args.method !== 'crypto')
175
+ return 'none';
176
+ const config = Client_1.Client.config(context);
177
+ yield context.sendFormatted({
178
+ photo: config.images.withdrawalCrypto,
179
+ header: '<b>🪙 Доступные сети для вывода:</b>',
180
+ }, {
181
+ reply_markup: {
182
+ inline_keyboard: [
183
+ [{ text: 'BTC', command: 'withdrawal', payload: { method: 'crypto', coin: 'btc' } }],
184
+ [{ text: 'ETH', command: 'withdrawal', payload: { method: 'crypto', coin: 'eth' } }],
185
+ [{ text: 'USDT (ERC-20)', command: 'withdrawal', payload: { method: 'crypto', coin: 'usdt-erc20' } }],
186
+ [{ text: 'USDT (TRC-20)', command: 'withdrawal', payload: { method: 'crypto', coin: 'usdt-trc20' } }],
187
+ ],
188
+ },
189
+ });
190
+ }))),
191
+ tslib_1.__param(4, (0, evogram_1.CommandArgument)({
192
+ name: 'requisites',
193
+ askAgain: true,
194
+ question: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ context, args, error }) {
195
+ var _b;
196
+ const config = Client_1.Client.config(context);
197
+ return (yield context.sendFormattedQuestion({
198
+ photo: args.method === 'crypto' ? config.images.withdrawalCrypto : config.images.withdrawal,
199
+ header: '<blockquote><b>✍️ Запрос на вывод средств</b></blockquote>',
200
+ footer: args.method === 'card'
201
+ ? '<i>ℹ️ Отправьте Ваш номер банковской карты</i>'
202
+ : args.method === 'sbp'
203
+ ? '<i>ℹ️ Отправьте Ваш номер телефона</i>'
204
+ : `<i>ℹ️ Отправьте Ваш адрес крипто-кошелька {{ ${(_b = args.coin) === null || _b === void 0 ? void 0 : _b.toUpperCase()} }}</i>`,
205
+ error: error === null || error === void 0 ? void 0 : error.message,
206
+ })).text;
207
+ }),
208
+ }, (params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
209
+ if (typeof params.value === 'object')
210
+ return params.value;
211
+ if (params.args.method === 'card') {
212
+ const requisites = yield (0, evogram_1.cardValidator)({})(params).catch(() => undefined);
213
+ if (!requisites)
214
+ throw new Error('Неверный формат реквизитов');
215
+ return yield requisites;
216
+ }
217
+ else if (params.args.method === 'sbp') {
218
+ const requisites = yield (0, evogram_1.phoneValidator)({})(params).catch(() => undefined);
219
+ if (!requisites || !/^\+?[7-8]\d{10,14}$/.test(params.value.replace(/ /g, '')))
220
+ throw new Error('Неверный формат реквизитов');
221
+ return yield requisites;
222
+ }
223
+ else if (params.args.method === 'crypto') {
224
+ if (params.args.method === 'crypto') {
225
+ switch (params.args.coin) {
226
+ case 'btc':
227
+ if (!/^([13][a-km-zA-HJ-NP-Z1-9]{25,34})|^(bc1[pqzry9x8gf2tvdw0s3jn54khce6mua7l]([qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}|[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58}))$/.test(params.value))
228
+ throw new Error('Невалидный адрес BTC-кошелька');
229
+ break;
230
+ case 'usdt-erc20':
231
+ case 'eth':
232
+ if (!/^(?:0x)?[0-9a-fA-F]{40}$/.test(params.value))
233
+ throw new Error('Невалидный адрес ETH-кошелька');
234
+ break;
235
+ case 'usdt-trc20':
236
+ if (!/^T[a-zA-HJ-NP-Z0-9]{33}$/.test(params.value))
237
+ throw new Error('Невалидный адрес TRC-20-кошелька');
238
+ break;
239
+ }
240
+ return { wallet: params.value };
241
+ }
242
+ }
243
+ throw new Error('Неверный формат реквизитов.');
244
+ }))),
245
+ tslib_1.__param(5, (0, evogram_1.CommandArgument)({
246
+ name: 'amount',
247
+ question: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ context, args, error, validateArgs }) {
248
+ const config = Client_1.Client.config(context);
249
+ let minAmountSetting = JSON.parse(context.state.settings.find((x) => x.name === 'minWithdrawal').value);
250
+ let minAmount = minAmountSetting[config.currency] || (yield minAmountSetting['RUB'].convert({ from: 'RUB', to: config.currency }));
251
+ validateArgs.minAmount = minAmount;
252
+ // prettier-ignore
253
+ return (yield context.sendFormattedQuestion({
254
+ photo: args.method === 'crypto' ? config.images.withdrawalCrypto : config.images.withdrawal,
255
+ header: '<blockquote><b>✍️ Запрос на вывод средств</b></blockquote>\n\n' +
256
+ 'Введите сумму, которую хотите вывести.\n' +
257
+ `<b>Ваш текущий баланс:</b> {{ ${yield context.user.db.balance.convert({ from: 'RUB', to: config.currency })} }}\n\n` +
258
+ `ℹ️ <b>Минимальная сумма для вывода:</b> {{ ${Number(minAmount).toLocaleString('ru')} ${config.currency.toUpperCase()} }}`,
259
+ error: error === null || error === void 0 ? void 0 : error.message,
260
+ })).text;
261
+ }),
262
+ }, (0, evogram_1.numberValidator)({ allowFloat: true, min: 0 }), (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, context, validateArgs }) {
263
+ const config = Client_1.Client.config(context);
264
+ const amountInRUB = yield value.convert({ from: config.currency, to: 'RUB' });
265
+ // prettier-ignore
266
+ if (value < validateArgs.minAmount)
267
+ throw new Error(`Минимальная сумма для вывода: ${Number(validateArgs.minAmount).toLocaleString('ru')} ${config.currency.toUpperCase()}`);
268
+ if (amountInRUB > context.user.db.balance)
269
+ throw new Error('Вы пытаетесь вывести больше, чем у вас есть');
270
+ return value;
271
+ }))),
272
+ tslib_1.__param(6, (0, evogram_1.CommandArgument)('confirm', (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ context, value, validateArgs, args }) {
273
+ var _b, _c, _d;
274
+ if (value)
275
+ return value;
276
+ const config = Client_1.Client.config(context);
277
+ // prettier-ignore
278
+ context.sendFormatted({
279
+ photo: args.method === 'crypto' ? config.images.withdrawalCrypto : config.images.withdrawal,
280
+ header: '<blockquote><b>✍️ Запрос на вывод средств</b></blockquote>\n\n' +
281
+ `<i>— Сумма вывода: {{ ${Number(validateArgs.amount).toLocaleString('ru')} ${config.currency.toUpperCase()} }}</i>\n` +
282
+ `<i>— Реквизиты: {{ ${((_b = validateArgs.requisites) === null || _b === void 0 ? void 0 : _b.formatted) || ((_c = validateArgs.requisites) === null || _c === void 0 ? void 0 : _c.wallet)} }}</i>\n` +
283
+ `<i>— Метод: {{ ${validateArgs.method === 'crypto' ? `Крипто-кошелек ${(_d = validateArgs.coin) === null || _d === void 0 ? void 0 : _d.toUpperCase()}` : args.method === 'sbp' ? 'Номер телефона' : 'Банковская карта'} }}</i>\n` +
284
+ (args.bank !== "none" ? `<i>— Банк: {{ ${args.bank} }}</i>\n` : '') +
285
+ `\n<i>— Ваш баланс после вывода: {{ ${yield (context.user.db.balance - (yield validateArgs.amount.convert({ from: config.currency, to: 'RUB' }))).convert({ from: 'RUB', to: config.currency })} }}</i>`,
286
+ }, {
287
+ reply_markup: {
288
+ inline_keyboard: [[{ text: '✅ Подтвердить', command: WithdrawalCommand, payload: Object.assign(Object.assign({}, args), { confirm: true }) }]],
289
+ },
290
+ });
291
+ }))),
292
+ tslib_1.__metadata("design:type", Function),
293
+ tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String, String, String, Object, Number, Boolean]),
294
+ tslib_1.__metadata("design:returntype", Promise)
295
+ ], WithdrawalCommand.prototype, "execute", null);
296
+ exports.WithdrawalCommand = WithdrawalCommand = WithdrawalCommand_1 = tslib_1.__decorate([
297
+ (0, evogram_1.CommandD)({ name: 'withdrawal', description: [{ text: 'Вывод средств' }, { language: 'en', text: 'Withdrawal' }], backButton: 'К выводу' })
298
+ ], WithdrawalCommand);
@@ -0,0 +1,3 @@
1
+ export * from './AdminWithdrawal.command';
2
+ export * from './GetWithdrawal.command';
3
+ export * from './Withdrawal.command';