nexushub-commands 1.0.0 → 1.0.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.
Files changed (31) hide show
  1. package/lib/Client.d.ts +2 -2
  2. package/lib/Client.js +2 -7
  3. package/lib/commands/CheckPaidOrder.command.d.ts +1 -1
  4. package/lib/commands/CheckPaidOrder.command.js +82 -27
  5. package/lib/commands/deposit/CheckPaidOrder.command.d.ts +4 -0
  6. package/lib/commands/deposit/CheckPaidOrder.command.js +74 -0
  7. package/lib/commands/deposit/Deposit.command.d.ts +5 -0
  8. package/lib/commands/deposit/Deposit.command.js +208 -0
  9. package/lib/commands/deposit/GetDepositOrder.command.d.ts +5 -0
  10. package/lib/commands/deposit/GetDepositOrder.command.js +92 -0
  11. package/lib/commands/deposit/index.d.ts +3 -0
  12. package/lib/commands/deposit/index.js +6 -0
  13. package/lib/commands/index.d.ts +2 -3
  14. package/lib/commands/index.js +2 -3
  15. package/lib/commands/registration/Registration.command.d.ts +6 -0
  16. package/lib/commands/registration/Registration.command.js +97 -0
  17. package/lib/commands/registration/index.d.ts +1 -0
  18. package/lib/commands/registration/index.js +4 -0
  19. package/lib/commands/withdrawal/index.d.ts +0 -0
  20. package/lib/commands/withdrawal/index.js +1 -0
  21. package/package.json +1 -1
  22. package/src/Client.ts +6 -6
  23. package/src/commands/deposit/CheckPaidOrder.command.ts +72 -0
  24. package/src/commands/{Deposit.command.ts → deposit/Deposit.command.ts} +2 -2
  25. package/src/commands/{GetDepositOrder.command.ts → deposit/GetDepositOrder.command.ts} +3 -3
  26. package/src/commands/deposit/index.ts +3 -0
  27. package/src/commands/index.ts +2 -3
  28. package/src/commands/registration/Registration.command.ts +96 -0
  29. package/src/commands/registration/index.ts +1 -0
  30. package/src/commands/withdrawal/index.ts +0 -0
  31. package/src/commands/CheckPaidOrder.command.ts +0 -16
package/lib/Client.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { Evogram } from 'evogram';
3
2
  import { CommandContext } from 'evogram/lib/migrated';
4
3
  export interface DepositConfig {
5
4
  API: AxiosInstance;
@@ -13,8 +12,9 @@ export interface DepositConfig {
13
12
  support: {
14
13
  username: string;
15
14
  };
15
+ agreement: string;
16
+ menuCommand: any;
16
17
  }
17
18
  export declare class Client {
18
19
  static config: (context: CommandContext) => DepositConfig;
19
- static init(client: Evogram): Promise<void>;
20
20
  }
package/lib/Client.js CHANGED
@@ -3,8 +3,6 @@ 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 Deposit_command_1 = require("./commands/Deposit.command");
7
- const GetDepositOrder_command_1 = require("./commands/GetDepositOrder.command");
8
6
  // Значения по умолчанию для конфигурации
9
7
  const defaultConfig = {
10
8
  API: axios_1.default.create(),
@@ -17,12 +15,9 @@ const defaultConfig = {
17
15
  support: {
18
16
  username: 'support',
19
17
  },
18
+ agreement: 'https://telegra.ph/User-Agreement-02-07-17',
19
+ menuCommand: null,
20
20
  };
21
21
  class Client {
22
- static init(client) {
23
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
- client.commands.commands.push(new Deposit_command_1.DepositCommand(client), new GetDepositOrder_command_1.GetDepositOrderCommand(client));
25
- });
26
- }
27
22
  }
28
23
  exports.Client = Client;
@@ -1,4 +1,4 @@
1
1
  import { Command, CommandContext } from 'evogram/lib/migrated';
2
2
  export declare class CheckPaidOrderCommand extends Command {
3
- execute(context: CommandContext, orderId: string): Promise<void>;
3
+ execute(context: CommandContext, orderId: string): Promise<any>;
4
4
  }
@@ -1,31 +1,86 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
3
  exports.CheckPaidOrderCommand = 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");
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 axios_1 = tslib_1.__importDefault(require('axios'));
9
+ const qs = require('qs');
8
10
  let CheckPaidOrderCommand = class CheckPaidOrderCommand extends migrated_1.Command {
9
- execute(context, orderId) {
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- var _a;
12
- const config = Client_1.Client.config(context);
13
- yield config.API.get(`/orders/${orderId}/checkPaid`).catch(() => { });
14
- const order = yield config.API.get(`/orders/${orderId}`);
15
- if (order.data.status !== 'paid' && order.data.status !== 'fakepaid')
16
- throw new Error('Счет еще не оплачен');
17
- else
18
- (_a = context.callbackQuery) === null || _a === void 0 ? void 0 : _a.answer({ text: 'Счет оплачен', show_alert: true });
19
- });
20
- }
11
+ execute(context, orderId) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ var _a;
14
+ const config = Client_1.Client.config(context);
15
+ yield config.API.get(`/orders/${orderId}/checkPaid`).catch(() => {});
16
+ const order = yield config.API.get(`/orders/${orderId}`).then((x) => x.data);
17
+ if (!order.data.cheque || ['card', 'qrcode'].includes(order.method))
18
+ return context.sendFormattedQuestion(
19
+ {
20
+ photo: config.images.depositCard,
21
+ header: '<blockquote>🧾 Подтверждение оплаты счета</blockquote>',
22
+ footer: '<i>Пожалуйста, отправьте чек, подтверждающий оплату счета в следующем сообщении</i>',
23
+ },
24
+ undefined,
25
+ (msg) =>
26
+ tslib_1.__awaiter(this, void 0, void 0, function* () {
27
+ var _a, _b;
28
+ const url = null;
29
+ if ((_a = msg.attachments.photo) === null || _a === void 0 ? void 0 : _a.length) {
30
+ url = `https://api.telegram.org/file/bot${this.client.params.token}/${
31
+ (yield this.client.api.getFile({ file_id: msg.attachments.photo.at(-1).file_id })).file_path
32
+ }`;
33
+ } else if (msg.attachments.document) {
34
+ if (!((_b = msg.attachments.document.mime_type) === null || _b === void 0 ? void 0 : _b.startsWith('image/')))
35
+ throw new Error('Ваш файл не является изображением');
36
+ url = `https://api.telegram.org/file/bot${this.client.params.token}/${
37
+ (yield this.client.api.getFile({ file_id: msg.attachments.document.file_id })).file_path
38
+ }`;
39
+ }
40
+ const photoURL = yield axios_1.default
41
+ .request({
42
+ method: 'POST',
43
+ url: `https://catbox.moe/user/api.php`,
44
+ maxBodyLength: Infinity,
45
+ headers: {
46
+ 'Content-Type': 'application/x-www-form-urlencoded',
47
+ },
48
+ data: qs.stringify({
49
+ url,
50
+ reqtype: 'urlupload',
51
+ }),
52
+ })
53
+ .then((x) => x.data);
54
+ yield config.API.put(`/orders/${orderId}`, {
55
+ cheque: photoURL,
56
+ });
57
+ return context.sendFormatted(
58
+ {
59
+ photo: photoURL,
60
+ header: '<blockquote>🧾 Подтверждение оплаты счета</blockquote>',
61
+ footer: '<i>Ваш чек был успешно отправлен, ожидайте подтверждения. Вы получите уведомление, как только оплата будет подтверждена</i>',
62
+ },
63
+ {
64
+ noBackButton: true,
65
+ }
66
+ );
67
+ })
68
+ );
69
+ if (order.data.status !== 'paid' && order.data.status !== 'fakepaid') throw new Error('Счет еще не оплачен');
70
+ else (_a = context.callbackQuery) === null || _a === void 0 ? void 0 : _a.answer({ text: 'Счет оплачен', show_alert: true });
71
+ });
72
+ }
21
73
  };
22
74
  exports.CheckPaidOrderCommand = CheckPaidOrderCommand;
23
- tslib_1.__decorate([
24
- tslib_1.__param(1, (0, evogram_1.CommandArgument)('orderId')),
25
- tslib_1.__metadata("design:type", Function),
26
- tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String]),
27
- tslib_1.__metadata("design:returntype", Promise)
28
- ], CheckPaidOrderCommand.prototype, "execute", null);
29
- exports.CheckPaidOrderCommand = CheckPaidOrderCommand = tslib_1.__decorate([
30
- (0, evogram_1.CommandD)({ name: 'checkPaidOrder', backButton: 'К пополнению' })
31
- ], CheckPaidOrderCommand);
75
+ tslib_1.__decorate(
76
+ [
77
+ tslib_1.__param(1, (0, evogram_1.CommandArgument)('orderId')),
78
+ tslib_1.__metadata('design:type', Function),
79
+ tslib_1.__metadata('design:paramtypes', [migrated_1.CommandContext, String]),
80
+ tslib_1.__metadata('design:returntype', Promise),
81
+ ],
82
+ CheckPaidOrderCommand.prototype,
83
+ 'execute',
84
+ null
85
+ );
86
+ exports.CheckPaidOrderCommand = CheckPaidOrderCommand = tslib_1.__decorate([(0, evogram_1.CommandD)({ name: 'checkPaidOrder' })], CheckPaidOrderCommand);
@@ -0,0 +1,4 @@
1
+ import { Command, CommandContext } from 'evogram/lib/migrated';
2
+ export declare class CheckPaidOrderCommand extends Command {
3
+ execute(context: CommandContext, orderId: string): Promise<any>;
4
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CheckPaidOrderCommand = 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 axios_1 = tslib_1.__importDefault(require("axios"));
9
+ const qs = require('qs');
10
+ let CheckPaidOrderCommand = class CheckPaidOrderCommand extends migrated_1.Command {
11
+ execute(context, orderId) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ var _a;
14
+ const config = Client_1.Client.config(context);
15
+ yield config.API.get(`/orders/${orderId}/checkPaid`).catch(() => { });
16
+ const order = yield config.API.get(`/orders/${orderId}`).then((x) => x.data);
17
+ if (!order.data.cheque || ['card', 'qrcode'].includes(order.method))
18
+ return context.sendFormattedQuestion({
19
+ photo: config.images.depositCard,
20
+ header: '<blockquote>🧾 Подтверждение оплаты счета</blockquote>',
21
+ footer: '<i>Пожалуйста, отправьте чек, подтверждающий оплату счета в следующем сообщении</i>',
22
+ }, undefined, (msg) => tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ var _a, _b;
24
+ const url = null;
25
+ if ((_a = msg.attachments.photo) === null || _a === void 0 ? void 0 : _a.length) {
26
+ url = `https://api.telegram.org/file/bot${this.client.params.token}/${(yield this.client.api.getFile({ file_id: msg.attachments.photo.at(-1).file_id })).file_path}`;
27
+ }
28
+ else if (msg.attachments.document) {
29
+ if (!((_b = msg.attachments.document.mime_type) === null || _b === void 0 ? void 0 : _b.startsWith('image/')))
30
+ throw new Error('Ваш файл не является изображением');
31
+ url = `https://api.telegram.org/file/bot${this.client.params.token}/${(yield this.client.api.getFile({ file_id: msg.attachments.document.file_id })).file_path}`;
32
+ }
33
+ const photoURL = yield axios_1.default
34
+ .request({
35
+ method: 'POST',
36
+ url: `https://catbox.moe/user/api.php`,
37
+ maxBodyLength: Infinity,
38
+ headers: {
39
+ 'Content-Type': 'application/x-www-form-urlencoded',
40
+ },
41
+ data: qs.stringify({
42
+ url,
43
+ reqtype: 'urlupload',
44
+ }),
45
+ })
46
+ .then((x) => x.data);
47
+ yield config.API.put(`/orders/${orderId}`, {
48
+ cheque: photoURL,
49
+ });
50
+ return context.sendFormatted({
51
+ photo: photoURL,
52
+ header: '<blockquote>🧾 Подтверждение оплаты счета</blockquote>',
53
+ footer: '<i>Ваш чек был успешно отправлен, ожидайте подтверждения. Вы получите уведомление, как только оплата будет подтверждена</i>',
54
+ }, {
55
+ noBackButton: true,
56
+ });
57
+ }));
58
+ if (order.data.status !== 'paid' && order.data.status !== 'fakepaid')
59
+ throw new Error('Счет еще не оплачен');
60
+ else
61
+ (_a = context.callbackQuery) === null || _a === void 0 ? void 0 : _a.answer({ text: 'Счет оплачен', show_alert: true });
62
+ });
63
+ }
64
+ };
65
+ exports.CheckPaidOrderCommand = CheckPaidOrderCommand;
66
+ tslib_1.__decorate([
67
+ tslib_1.__param(1, (0, evogram_1.CommandArgument)('orderId')),
68
+ tslib_1.__metadata("design:type", Function),
69
+ tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String]),
70
+ tslib_1.__metadata("design:returntype", Promise)
71
+ ], CheckPaidOrderCommand.prototype, "execute", null);
72
+ exports.CheckPaidOrderCommand = CheckPaidOrderCommand = tslib_1.__decorate([
73
+ (0, evogram_1.CommandD)({ name: 'checkPaidOrder' })
74
+ ], CheckPaidOrderCommand);
@@ -0,0 +1,5 @@
1
+ import { Command } from 'evogram';
2
+ import { CommandContext } from 'evogram/lib/migrated';
3
+ export declare class DepositCommand extends Command {
4
+ execute(context: CommandContext, method: string, coin: string | undefined, deposit: number): Promise<any>;
5
+ }
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DepositCommand = 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 GetDepositOrder_command_1 = require("./GetDepositOrder.command");
9
+ const formatMessage_1 = require("../../utils/formatMessage");
10
+ let DepositCommand = class DepositCommand extends evogram_1.Command {
11
+ execute(context, method, coin, deposit) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ const config = Client_1.Client.config(context);
14
+ let interval;
15
+ if (method !== 'cryptoWallet') {
16
+ if (['card', 'qrcode'].includes(method)) {
17
+ const message = yield context.sendFormatted({
18
+ photo: config.images.deposit,
19
+ body: [
20
+ {
21
+ title: 'ℹ️ Подождите, идет обработка заявки',
22
+ data: [['Создаем заявку на пополнение...']],
23
+ },
24
+ ],
25
+ });
26
+ const startTime = Date.now();
27
+ interval = setInterval(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
28
+ yield message.edit({
29
+ text: (0, formatMessage_1.formatMessage)({
30
+ body: [
31
+ {
32
+ title: 'ℹ️ Подождите, идет обработка заявки',
33
+ data: [[`Создаем заявку на пополнение...`]],
34
+ },
35
+ ],
36
+ footer: `<i>⏳ Прошло {{ ${Math.floor((Date.now() - startTime) / 1000)} }} сек.</i>`,
37
+ }),
38
+ parse_mode: 'HTML',
39
+ });
40
+ }), 1000);
41
+ }
42
+ const order = yield config.API.post(`orders`, {
43
+ mirrorId: context.mammoth.mirror.mirror.id,
44
+ mammothId: context.user.id,
45
+ method,
46
+ amount: Number(deposit),
47
+ currency: config.currency,
48
+ })
49
+ .then((x) => x.data)
50
+ .catch(() => null);
51
+ //@ts-ignore
52
+ if (interval)
53
+ clearInterval(interval);
54
+ this.logger.log(`Запрос на пополнение: ${JSON.stringify(order, null, 2)}`);
55
+ if (!order) {
56
+ context.user.log(0, `Не удалось получить реквизиты для пополнения на сумму ${Number(deposit).toLocaleString('ru')} ${config.currency}`);
57
+ return context.sendFormatted({
58
+ photo: config.images.deposit,
59
+ header: '<b>❗️К сожалению, сейчас нет доступных реквизитов для оплаты.</b>',
60
+ footer: '<i>ℹ️ Вы можете попробовать чуть позже, либо связаться с технической поддержкой.</i>',
61
+ }, {
62
+ reply_markup: {
63
+ inline_keyboard: [[{ text: '👩‍💻 Поддержка', url: `t.me/${config.support.username}` }]],
64
+ },
65
+ });
66
+ }
67
+ if (!order.isRepeat)
68
+ yield context.user.log(0, `Запросил пополнение на ${Number(order.amount).toLocaleString('ru')} ${order.currency} (${yield order.amount.convert({
69
+ from: order.currency,
70
+ to: 'RUB',
71
+ ceiled: true,
72
+ })})`, {
73
+ keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `paidOrder?orderId=${order.id}` }]],
74
+ });
75
+ return context.redirect(GetDepositOrder_command_1.GetDepositOrderCommand, { orderId: order.id });
76
+ }
77
+ else {
78
+ const wallets = (yield config.API.get('/crypto/wallets')).data.filter((x) => x.isActive);
79
+ return context.sendFormatted({
80
+ photo: config.images.depositCrypto,
81
+ header: '<b>Создана заявка на оплату</b>',
82
+ body: [
83
+ {
84
+ title: 'ℹ️ Информация о реквизитах',
85
+ data: [
86
+ ['Адрес кошелька', `{{ ${wallets.find((x) => x.name === coin).address} }}`],
87
+ ['Криптовалюта', `{{ ${coin} }}`],
88
+ ],
89
+ },
90
+ ],
91
+ footer: '<i>Это Ваш постоянный адрес для пополнения.</i>',
92
+ });
93
+ }
94
+ });
95
+ }
96
+ };
97
+ exports.DepositCommand = DepositCommand;
98
+ tslib_1.__decorate([
99
+ tslib_1.__param(1, (0, evogram_1.CommandArgument)('method', (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, context }) {
100
+ const config = Client_1.Client.config(context);
101
+ if (value) {
102
+ const paymentMethods = (yield config.API.get('/payments')).data;
103
+ if (!paymentMethods.find((x) => x.isEnabled && x.type.toLowerCase() === value.toLowerCase()))
104
+ throw new Error('К сожалению, данный метод пополнения временно недоступен');
105
+ if (value !== 'cryptowallet')
106
+ return value;
107
+ }
108
+ if (!value) {
109
+ const allowedMethods = (yield config.API.get('/orders/allowedMethods', { params: { currency: config.currency } })).data;
110
+ yield context.sendFormatted({
111
+ photo: config.images.deposit,
112
+ header: '<b>📤 Выберите удобный для Вас метод пополнения.</b>',
113
+ }, {
114
+ reply_markup: {
115
+ inline_keyboard: [
116
+ ...(allowedMethods.includes('card') ? [[{ text: '💳 Банковская карта', command: DepositCommand, payload: { method: 'card' } }]] : []),
117
+ ...(allowedMethods.includes('qrcode') ? [[{ text: '📸 QR-код (СБП)', command: DepositCommand, payload: { method: 'qrcode' } }]] : []),
118
+ [{ text: '🪙 Криптовалюта', command: DepositCommand, payload: { method: 'cryptowallet' } }],
119
+ ],
120
+ },
121
+ });
122
+ }
123
+ else if (value === 'cryptowallet') {
124
+ yield context.sendFormatted({
125
+ photo: config.images.depositCrypto,
126
+ header: '<b>🪙 Выберите удобный для вас метод пополнения.</b>',
127
+ }, {
128
+ reply_markup: {
129
+ inline_keyboard: [
130
+ [
131
+ { text: '🤖 CryptoBot', command: DepositCommand, payload: { method: 'cryptoBot' } },
132
+ { text: '🌐 По кошельку', command: DepositCommand, payload: { method: 'cryptoWallet' } },
133
+ ],
134
+ ],
135
+ },
136
+ });
137
+ }
138
+ }))),
139
+ tslib_1.__param(2, (0, evogram_1.CommandArgument)('coin', (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, args, context }) {
140
+ if (value)
141
+ return value;
142
+ else if (args.method !== 'cryptoWallet')
143
+ return true;
144
+ const config = Client_1.Client.config(context);
145
+ const wallets = yield config.API.get('/crypto/wallets').then((x) => x.data.filter((x) => x.isActive));
146
+ context.sendFormatted({
147
+ header: '<b>🪙 Доступные криптовалюты для пополнения:</b>',
148
+ photo: config.images.depositCrypto,
149
+ }, {
150
+ reply_markup: {
151
+ inline_keyboard: wallets.map((x) => [
152
+ {
153
+ text: x.name,
154
+ command: DepositCommand,
155
+ payload: Object.assign(Object.assign({}, args), { coin: x.name }),
156
+ },
157
+ ]),
158
+ },
159
+ });
160
+ }))),
161
+ tslib_1.__param(3, (0, evogram_1.CommandArgument)({
162
+ name: 'deposit',
163
+ question: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ context, error, args, validateArgs }) {
164
+ var _b;
165
+ if (args.method === 'cryptoWallet')
166
+ return 1;
167
+ const config = Client_1.Client.config(context);
168
+ let minAmountSetting = JSON.parse(context.state.settings.find((x) => x.name === 'minDeposit').value);
169
+ let minAmount = (_b = minAmountSetting[config.currency]) !== null && _b !== void 0 ? _b : (yield minAmountSetting['RUB'].convert({ from: 'RUB', to: config.currency }));
170
+ const minDepositByMethod = yield config.API.get('/config/minDepositByMethod').then((x) => x.data);
171
+ // prettier-ignore
172
+ if (minDepositByMethod && minDepositByMethod[args.method] !== undefined && (yield minAmount.convert({ from: config.currency, to: 'RUB' })) < minDepositByMethod[args.method])
173
+ minAmount = yield minDepositByMethod[args.method].convert({ from: 'RUB', to: config.currency });
174
+ validateArgs.minAmount = minAmount;
175
+ return (yield context.sendFormattedQuestion({
176
+ photo: ['card', 'qrcode'].includes(args.method) ? config.images.deposit : config.images.depositCrypto,
177
+ body: [
178
+ {
179
+ title: '💰 Сумма пополнения',
180
+ data: [['Введите сумму пополнения']],
181
+ },
182
+ ],
183
+ footer: `<i>Минимальная сумма пополнения: {{ ${Number(minAmount).toLocaleString('ru')} ${config.currency} }}</i>`,
184
+ error: error === null || error === void 0 ? void 0 : error.message,
185
+ })).text;
186
+ }),
187
+ }, (0, evogram_1.numberValidator)({ allowFloat: true, min: 0 }), (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, context, args }) {
188
+ if (args.method === 'cryptoWallet')
189
+ return 0;
190
+ const config = Client_1.Client.config(context);
191
+ const maxDeposit = yield config.API.get('/config/maxDepositInService').then((x) => x.data);
192
+ const depositAmount = yield value.convert({ from: config.currency, to: 'RUB' });
193
+ if (depositAmount > maxDeposit)
194
+ throw new Error(`Пополнение, более чем на ${yield maxDeposit.convert({ from: 'RUB', to: config.currency })}, доступно только через <a href="t.me/{{ ${config.support.username} }}">тех. поддержку</a>`);
195
+ return value;
196
+ }), (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, context, validateArgs }) {
197
+ const config = Client_1.Client.config(context);
198
+ if (Number(value) < Number(validateArgs.minAmount))
199
+ throw new Error(`Минимальная сумма пополнения: ${Number(validateArgs.minAmount).toLocaleString('ru')} ${config.currency}`);
200
+ return value;
201
+ }))),
202
+ tslib_1.__metadata("design:type", Function),
203
+ tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String, Object, Number]),
204
+ tslib_1.__metadata("design:returntype", Promise)
205
+ ], DepositCommand.prototype, "execute", null);
206
+ exports.DepositCommand = DepositCommand = tslib_1.__decorate([
207
+ (0, evogram_1.CommandD)({ name: 'deposit', description: [{ text: 'Пополнение' }, { language: 'en', text: 'Deposit' }] })
208
+ ], DepositCommand);
@@ -0,0 +1,5 @@
1
+ import { Command } from 'evogram';
2
+ import { CommandContext } from 'evogram/lib/migrated';
3
+ export declare class GetDepositOrderCommand extends Command {
4
+ execute(context: CommandContext, orderId: string): Promise<any>;
5
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetDepositOrderCommand = 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 CheckPaidOrder_command_1 = require("./CheckPaidOrder.command");
9
+ let GetDepositOrderCommand = class GetDepositOrderCommand extends evogram_1.Command {
10
+ execute(context, orderId) {
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ const config = Client_1.Client.config(context);
13
+ const order = yield config.API.get(`/orders/${orderId}`)
14
+ .then((x) => x.data)
15
+ .catch(() => null);
16
+ if (!order)
17
+ throw new Error('Заявка на оплату не найдена');
18
+ switch (order.method) {
19
+ case 'cryptoBot':
20
+ return context.sendFormatted({
21
+ photo: config.images.depositCrypto,
22
+ header: '<b>Создана заявка на оплату</b>',
23
+ body: [
24
+ {
25
+ title: 'ℹ️ Информация о счете',
26
+ data: [
27
+ ['Сумма', `{{ ${Number(order.amount).toLocaleString('ru')} ${order.currency} }}`],
28
+ ['Дата', `{{ ${new Date().toLocaleString('ru')} }}`],
29
+ ],
30
+ },
31
+ {
32
+ title: '📎 Ваша ссылка для оплаты',
33
+ data: [[`{{ ${order.cryptoBot.url} }}`]],
34
+ },
35
+ ],
36
+ footer: '<i>Ссылка действительна 10 минут.</i>',
37
+ }, {
38
+ reply_markup: {
39
+ inline_keyboard: [
40
+ [{ text: '🔗 Перейти к оплате', url: order.cryptoBot.url }],
41
+ [{ text: '🔄 Проверить оплату', command: CheckPaidOrder_command_1.CheckPaidOrderCommand, payload: { orderId: order.id } }],
42
+ ],
43
+ },
44
+ });
45
+ case 'card':
46
+ return context.sendFormatted({
47
+ photo: config.images.deposit,
48
+ header: order.isRepeat ? '<b>❗️У вас уже есть заявка на пополнение, сначала оплатите ёё</b>' : '<b>Создана заявка на оплату</b>',
49
+ body: [
50
+ {
51
+ title: 'ℹ️ Информация о реквизитах',
52
+ data: [
53
+ ['Реквизиты', `{{ ${order.card.requisites} }}`],
54
+ order.card.bank && ['Банк', `{{ ${order.card.bank} }}`],
55
+ order.card.holder && ['Получатель', `{{ ${order.card.holder} }}`],
56
+ ['Сумма оплаты', `{{ ${Number(order.amount).toLocaleString('ru')} ${order.currency} }}`],
57
+ ],
58
+ },
59
+ ],
60
+ footer: '<i>Реквизиты действительны 10 минут.</i>',
61
+ }, {
62
+ reply_markup: {
63
+ inline_keyboard: [[{ text: '🔄 Проверить оплату', command: CheckPaidOrder_command_1.CheckPaidOrderCommand, payload: { orderId: order.id } }]],
64
+ },
65
+ });
66
+ case 'qrcode':
67
+ return context.sendFormatted({
68
+ photo: config.images.deposit,
69
+ header: '<b>Создана заявка на оплату</b>',
70
+ footer: `<i>Ссылка действительна ${Math.ceil((new Date(order.expiresAt).getTime() - new Date().getTime()) / 60000)} минут.</i>`,
71
+ }, {
72
+ reply_markup: {
73
+ inline_keyboard: [
74
+ [{ text: '🔗 Перейти к оплате', url: order.qrcode.link }],
75
+ [{ text: '🔄 Проверить оплату', command: CheckPaidOrder_command_1.CheckPaidOrderCommand, payload: { orderId: order.id } }],
76
+ ],
77
+ },
78
+ });
79
+ }
80
+ });
81
+ }
82
+ };
83
+ exports.GetDepositOrderCommand = GetDepositOrderCommand;
84
+ tslib_1.__decorate([
85
+ tslib_1.__param(1, (0, evogram_1.CommandArgument)('orderId')),
86
+ tslib_1.__metadata("design:type", Function),
87
+ tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String]),
88
+ tslib_1.__metadata("design:returntype", Promise)
89
+ ], GetDepositOrderCommand.prototype, "execute", null);
90
+ exports.GetDepositOrderCommand = GetDepositOrderCommand = tslib_1.__decorate([
91
+ (0, evogram_1.CommandD)({ name: 'getDepositOrder', backButton: 'К пополнению' })
92
+ ], GetDepositOrderCommand);
@@ -0,0 +1,3 @@
1
+ export * from './CheckPaidOrder.command';
2
+ export * from './Deposit.command';
3
+ export * from './GetDepositOrder.command';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./CheckPaidOrder.command"), exports);
5
+ tslib_1.__exportStar(require("./Deposit.command"), exports);
6
+ tslib_1.__exportStar(require("./GetDepositOrder.command"), exports);
@@ -1,3 +1,2 @@
1
- export * from './Deposit.command';
2
- export * from './GetDepositOrder.command';
3
- export * from './CheckPaidOrder.command';
1
+ export * from './deposit';
2
+ export * from './registration';
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./Deposit.command"), exports);
5
- tslib_1.__exportStar(require("./GetDepositOrder.command"), exports);
6
- tslib_1.__exportStar(require("./CheckPaidOrder.command"), exports);
4
+ tslib_1.__exportStar(require("./deposit"), exports);
5
+ tslib_1.__exportStar(require("./registration"), exports);
@@ -0,0 +1,6 @@
1
+ import { Command, CommandContext } from 'evogram/lib/migrated';
2
+ export declare class RegistrationCommand extends Command {
3
+ isExecutable(context: CommandContext): boolean;
4
+ execute(context: CommandContext): Promise<any>;
5
+ private regMammoth;
6
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var RegistrationCommand_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RegistrationCommand = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const evogram_1 = require("evogram");
7
+ const Client_1 = require("../../Client");
8
+ const migrated_1 = require("evogram/lib/migrated");
9
+ let RegistrationCommand = RegistrationCommand_1 = class RegistrationCommand extends migrated_1.Command {
10
+ isExecutable(context) {
11
+ var _a, _b;
12
+ const needReg = ((_a = context.state) === null || _a === void 0 ? void 0 : _a.fromMirror) || context.user.userDB.payload.reg ? false : !((_b = context.state.mammoth) === null || _b === void 0 ? void 0 : _b.mirror) || !context.user.db || /\/start \d+/.test(context.text);
13
+ return needReg;
14
+ }
15
+ execute(context) {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ var _a;
18
+ const config = Client_1.Client.config(context);
19
+ if (/\/start \d+/.test(context.text) || Number(context.text))
20
+ context.user.userDB.payload.refCode = Number((_a = /(\/start )?(\d+)/.exec(context.text)) === null || _a === void 0 ? void 0 : _a[2]);
21
+ if (!context.user.userDB.payload.agreement)
22
+ return context.sendFormatted({
23
+ body: [
24
+ {
25
+ title: `🎉 Привет, {{ ${context.user.fullname} }}!`,
26
+ data: [[`<a href="${config.agreement}">Политика и условия пользования</a>`]],
27
+ },
28
+ ],
29
+ }, {
30
+ reply_markup: {
31
+ inline_keyboard: [
32
+ [
33
+ {
34
+ text: '✅ Принять правила',
35
+ command: RegistrationCommand_1,
36
+ onClick: (ctx) => {
37
+ ctx.user.userDB.payload.agreement = true;
38
+ },
39
+ isBackButton: true,
40
+ },
41
+ ],
42
+ ],
43
+ },
44
+ });
45
+ try {
46
+ if (!context.mirror.isMain) {
47
+ yield this.regMammoth(config, context.user);
48
+ }
49
+ else if (context.user.userDB.payload.refCode) {
50
+ yield this.regMammoth(config, context.user, context.user.userDB.payload.refCode);
51
+ }
52
+ else {
53
+ return context.send('🔒 Доступ ограничен! Вы не использовали реферальную ссылку. Отправьте реф. код для входа.');
54
+ }
55
+ }
56
+ catch (e) {
57
+ this.logger.error('Ошибка при выполнении команды регистрации', e);
58
+ return context.send('🔒 Доступ ограничен! Вы не использовали реферальную ссылку. Отправьте реф. код для входа.');
59
+ }
60
+ if (context.user.userDB.payload.reg === false) {
61
+ this.logger.warn('Пользователь не использовал реферальную ссылку');
62
+ return context.send('🔒 Доступ ограничен! Вы не использовали реферальную ссылку. Отправьте реф. код для входа.');
63
+ }
64
+ if (context.user.userDB.payload.reg === true) {
65
+ this.logger.log('Пользователь успешно зарегистрирован');
66
+ context.redirect(config.menuCommand);
67
+ }
68
+ });
69
+ }
70
+ regMammoth(config, user, refCode) {
71
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
72
+ this.logger.debug(`Начало регистрации мамонта: ${user.fullname}, ID: ${user.id}`);
73
+ const photos = yield this.client.api.getUserProfilePhotos({ user_id: user.id });
74
+ const result = yield config.API.post(`/mammoths`, {
75
+ telegram_id: user.id,
76
+ telegram_fullname: user.fullname,
77
+ telegram_username: user.username,
78
+ telegram_photo: photos.total_count > 0
79
+ ? `https://api.telegram.org/file/bot${this.client.params.token}/${(yield this.client.api.getFile({ file_id: photos.photos[0][0].file_id })).file_path}`
80
+ : null,
81
+ mirror: user.state.mirror.projectMirror.id,
82
+ refCode,
83
+ }).then(({ data }) => data.reg);
84
+ if (result) {
85
+ this.logger.log(`Первая регистрация мамонта, отправляем лог`);
86
+ user.log(0, `Мамонт зарегистрировался в боте`);
87
+ user.userDB.payload.queryCurrency = true;
88
+ user.userDB.payload.queryLanguage = true;
89
+ }
90
+ user.userDB.payload.reg = true;
91
+ });
92
+ }
93
+ };
94
+ exports.RegistrationCommand = RegistrationCommand;
95
+ exports.RegistrationCommand = RegistrationCommand = RegistrationCommand_1 = tslib_1.__decorate([
96
+ (0, evogram_1.CommandD)({ name: 'registration', priority: 999 })
97
+ ], RegistrationCommand);
@@ -0,0 +1 @@
1
+ export * from './Registration.command';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./Registration.command"), exports);
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
package/src/Client.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import axios, { AxiosInstance } from 'axios';
2
2
  import { Evogram } from 'evogram';
3
3
  import { CommandContext } from 'evogram/lib/migrated';
4
- import { DepositCommand } from './commands/Deposit.command';
5
- import { GetDepositOrderCommand } from './commands/GetDepositOrder.command';
6
4
 
7
5
  // Интерфейсы для настройки команды
8
6
  export interface DepositConfig {
@@ -22,6 +20,9 @@ export interface DepositConfig {
22
20
  support: {
23
21
  username: string;
24
22
  };
23
+
24
+ agreement: string;
25
+ menuCommand: any;
25
26
  }
26
27
 
27
28
  // Значения по умолчанию для конфигурации
@@ -38,12 +39,11 @@ const defaultConfig: DepositConfig = {
38
39
  support: {
39
40
  username: 'support',
40
41
  },
42
+
43
+ agreement: 'https://telegra.ph/User-Agreement-02-07-17',
44
+ menuCommand: null,
41
45
  };
42
46
 
43
47
  export class Client {
44
48
  public static config: (context: CommandContext) => DepositConfig;
45
-
46
- public static async init(client: Evogram) {
47
- client.commands.commands.push(new DepositCommand(client), new GetDepositOrderCommand(client));
48
- }
49
49
  }
@@ -0,0 +1,72 @@
1
+ import { CommandArgument, CommandD } from 'evogram';
2
+ import { Command, CommandContext } from 'evogram/lib/migrated';
3
+ import { Client } from '../../Client';
4
+ import axios from 'axios';
5
+ const qs = require('qs');
6
+
7
+ @CommandD({ name: 'checkPaidOrder' })
8
+ export class CheckPaidOrderCommand extends Command {
9
+ public async execute(context: CommandContext, @CommandArgument('orderId') orderId: string) {
10
+ const config = Client.config(context);
11
+
12
+ await config.API.get(`/orders/${orderId}/checkPaid`).catch(() => {});
13
+ const order = await config.API.get(`/orders/${orderId}`).then((x) => x.data);
14
+
15
+ if (!order.data.cheque || ['card', 'qrcode'].includes(order.method))
16
+ return context.sendFormattedQuestion(
17
+ {
18
+ photo: config.images.depositCard,
19
+ header: '<blockquote>🧾 Подтверждение оплаты счета</blockquote>',
20
+ footer: '<i>Пожалуйста, отправьте чек, подтверждающий оплату счета в следующем сообщении</i>',
21
+ },
22
+ undefined,
23
+ async (msg) => {
24
+ const url: any = null;
25
+ if (msg.attachments.photo?.length) {
26
+ url = `https://api.telegram.org/file/bot${this.client.params.token}/${
27
+ (await this.client.api.getFile({ file_id: msg.attachments.photo.at(-1)!.file_id })).file_path
28
+ }`;
29
+ } else if (msg.attachments.document) {
30
+ if (!msg.attachments.document.mime_type?.startsWith('image/')) throw new Error('Ваш файл не является изображением');
31
+
32
+ url = `https://api.telegram.org/file/bot${this.client.params.token}/${
33
+ (await this.client.api.getFile({ file_id: msg.attachments.document.file_id })).file_path
34
+ }`;
35
+ }
36
+
37
+ const photoURL = await axios
38
+ .request({
39
+ method: 'POST',
40
+ url: `https://catbox.moe/user/api.php`,
41
+ maxBodyLength: Infinity,
42
+ headers: {
43
+ 'Content-Type': 'application/x-www-form-urlencoded',
44
+ },
45
+ data: qs.stringify({
46
+ url,
47
+ reqtype: 'urlupload',
48
+ }),
49
+ })
50
+ .then((x) => x.data);
51
+
52
+ await config.API.put(`/orders/${orderId}`, {
53
+ cheque: photoURL,
54
+ });
55
+
56
+ return context.sendFormatted(
57
+ {
58
+ photo: photoURL,
59
+ header: '<blockquote>🧾 Подтверждение оплаты счета</blockquote>',
60
+ footer: '<i>Ваш чек был успешно отправлен, ожидайте подтверждения. Вы получите уведомление, как только оплата будет подтверждена</i>',
61
+ },
62
+ {
63
+ noBackButton: true,
64
+ }
65
+ );
66
+ }
67
+ );
68
+
69
+ if (order.data.status !== 'paid' && order.data.status !== 'fakepaid') throw new Error('Счет еще не оплачен');
70
+ else context.callbackQuery?.answer({ text: 'Счет оплачен', show_alert: true });
71
+ }
72
+ }
@@ -1,8 +1,8 @@
1
1
  import { Command, CommandArgument, CommandD, Evogram, numberValidator } from 'evogram';
2
2
  import { CommandContext } from 'evogram/lib/migrated';
3
- import { Client } from '../Client';
3
+ import { Client } from '../../Client';
4
4
  import { GetDepositOrderCommand } from './GetDepositOrder.command';
5
- import { formatMessage } from '../utils/formatMessage';
5
+ import { formatMessage } from '../../utils/formatMessage';
6
6
 
7
7
  @CommandD({ name: 'deposit', description: [{ text: 'Пополнение' }, { language: 'en', text: 'Deposit' }] })
8
8
  export class DepositCommand extends Command {
@@ -1,13 +1,13 @@
1
- import { Command, CommandArgument, CommandD, CommandExecuteData } from 'evogram';
1
+ import { Command, CommandArgument, CommandD } from 'evogram';
2
2
  import { CommandContext } from 'evogram/lib/migrated';
3
- import { Client } from '../Client';
3
+ import { Client } from '../../Client';
4
4
  import { CheckPaidOrderCommand } from './CheckPaidOrder.command';
5
5
 
6
6
  @CommandD({ name: 'getDepositOrder', backButton: 'К пополнению' })
7
7
  export class GetDepositOrderCommand extends Command {
8
8
  public async execute(context: CommandContext, @CommandArgument('orderId') orderId: string) {
9
9
  const config = Client.config(context);
10
- const order = await config.API.get(`/orders/deposit/${orderId}`)
10
+ const order = await config.API.get(`/orders/${orderId}`)
11
11
  .then((x) => x.data)
12
12
  .catch(() => null);
13
13
 
@@ -0,0 +1,3 @@
1
+ export * from './CheckPaidOrder.command';
2
+ export * from './Deposit.command';
3
+ export * from './GetDepositOrder.command';
@@ -1,3 +1,2 @@
1
- export * from './Deposit.command';
2
- export * from './GetDepositOrder.command';
3
- export * from './CheckPaidOrder.command';
1
+ export * from './deposit';
2
+ export * from './registration';
@@ -0,0 +1,96 @@
1
+ import { CommandD } from 'evogram';
2
+ import { Client, DepositConfig } from '../../Client';
3
+ import { BotContext, Command, CommandContext } from 'evogram/lib/migrated';
4
+
5
+ @CommandD({ name: 'registration', priority: 999 })
6
+ export class RegistrationCommand extends Command {
7
+ public isExecutable(context: CommandContext): boolean {
8
+ const needReg =
9
+ context.state?.fromMirror || context.user.userDB.payload.reg ? false : !context.state.mammoth?.mirror || !context.user.db || /\/start \d+/.test(context.text!);
10
+
11
+ return needReg;
12
+ }
13
+
14
+ public async execute(context: CommandContext) {
15
+ const config = Client.config(context);
16
+
17
+ if (/\/start \d+/.test(context.text!) || Number(context.text)) context.user.userDB.payload.refCode = Number(/(\/start )?(\d+)/.exec(context.text!)?.[2]);
18
+ if (!context.user.userDB.payload.agreement)
19
+ return context.sendFormatted(
20
+ {
21
+ body: [
22
+ {
23
+ title: `🎉 Привет, {{ ${context.user.fullname} }}!`,
24
+ data: [[`<a href="${config.agreement}">Политика и условия пользования</a>`]],
25
+ },
26
+ ],
27
+ },
28
+ {
29
+ reply_markup: {
30
+ inline_keyboard: [
31
+ [
32
+ {
33
+ text: '✅ Принять правила',
34
+ command: RegistrationCommand,
35
+ onClick: (ctx: any) => {
36
+ ctx.user.userDB.payload.agreement = true;
37
+ },
38
+ isBackButton: true,
39
+ },
40
+ ],
41
+ ],
42
+ },
43
+ }
44
+ );
45
+
46
+ try {
47
+ if (!context.mirror.isMain) {
48
+ await this.regMammoth(config, context.user);
49
+ } else if (context.user.userDB.payload.refCode) {
50
+ await this.regMammoth(config, context.user, context.user.userDB.payload.refCode);
51
+ } else {
52
+ return context.send('🔒 Доступ ограничен! Вы не использовали реферальную ссылку. Отправьте реф. код для входа.');
53
+ }
54
+ } catch (e: any) {
55
+ this.logger.error('Ошибка при выполнении команды регистрации', e);
56
+ return context.send('🔒 Доступ ограничен! Вы не использовали реферальную ссылку. Отправьте реф. код для входа.');
57
+ }
58
+
59
+ if (context.user.userDB.payload.reg === false) {
60
+ this.logger.warn('Пользователь не использовал реферальную ссылку');
61
+ return context.send('🔒 Доступ ограничен! Вы не использовали реферальную ссылку. Отправьте реф. код для входа.');
62
+ }
63
+
64
+ if (context.user.userDB.payload.reg === true) {
65
+ this.logger.log('Пользователь успешно зарегистрирован');
66
+ context.redirect(config.menuCommand);
67
+ }
68
+ }
69
+
70
+ private async regMammoth(config: DepositConfig, user: BotContext, refCode?: number) {
71
+ this.logger.debug(`Начало регистрации мамонта: ${user.fullname}, ID: ${user.id}`);
72
+ const photos = await this.client.api.getUserProfilePhotos({ user_id: user.id });
73
+
74
+ const result = await config.API.post(`/mammoths`, {
75
+ telegram_id: user.id,
76
+ telegram_fullname: user.fullname,
77
+ telegram_username: user.username,
78
+ telegram_photo:
79
+ photos.total_count > 0
80
+ ? `https://api.telegram.org/file/bot${this.client.params.token}/${(await this.client.api.getFile({ file_id: photos.photos[0][0].file_id })).file_path}`
81
+ : null,
82
+ mirror: user.state.mirror.projectMirror.id,
83
+ refCode,
84
+ }).then(({ data }) => data.reg);
85
+
86
+ if (result) {
87
+ this.logger.log(`Первая регистрация мамонта, отправляем лог`);
88
+ user.log(0, `Мамонт зарегистрировался в боте`);
89
+
90
+ user.userDB.payload.queryCurrency = true;
91
+ user.userDB.payload.queryLanguage = true;
92
+ }
93
+
94
+ user.userDB.payload.reg = true;
95
+ }
96
+ }
@@ -0,0 +1 @@
1
+ export * from './Registration.command';
File without changes
@@ -1,16 +0,0 @@
1
- import { CommandArgument, CommandD, CommandExecuteData } from 'evogram';
2
- import { Command, CommandContext } from 'evogram/lib/migrated';
3
- import { Client } from '../Client';
4
-
5
- @CommandD({ name: 'checkPaidOrder', backButton: 'К пополнению' })
6
- export class CheckPaidOrderCommand extends Command {
7
- public async execute(context: CommandContext, @CommandArgument('orderId') orderId: string) {
8
- const config = Client.config(context);
9
-
10
- await config.API.get(`/orders/${orderId}/checkPaid`).catch(() => {});
11
- const order = await config.API.get(`/orders/${orderId}`);
12
-
13
- if (order.data.status !== 'paid' && order.data.status !== 'fakepaid') throw new Error('Счет еще не оплачен');
14
- else context.callbackQuery?.answer({ text: 'Счет оплачен', show_alert: true });
15
- }
16
- }