nexushub-commands 1.4.1 → 1.5.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/commands/deposit/Deposit.command.js +121 -122
- package/lib/commands/deposit/GetDepositOrder.command.d.ts +1 -1
- package/lib/commands/deposit/GetDepositOrder.command.js +25 -3
- package/package.json +1 -1
- package/src/commands/deposit/Deposit.command.ts +138 -136
- package/src/commands/deposit/GetDepositOrder.command.ts +30 -2
|
@@ -28,54 +28,39 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
|
|
|
28
28
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
const config = Client_1.Client.config(context);
|
|
30
30
|
let interval;
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
if (['card', 'qrcode'].includes(method)) {
|
|
32
|
+
const message = yield context.sendFormatted({
|
|
33
|
+
photo: config.images.deposit,
|
|
34
|
+
body: [
|
|
35
|
+
{
|
|
36
|
+
title: 'ℹ️ Подождите, идет обработка заявки',
|
|
37
|
+
data: [['Создаем заявку на пополнение...']],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
const startTime = Date.now();
|
|
42
|
+
interval = setInterval(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
yield message.edit({
|
|
44
|
+
text: (0, formatMessage_1.formatMessage)({
|
|
45
|
+
body: [
|
|
46
|
+
{
|
|
47
|
+
title: 'ℹ️ Подождите, идет обработка заявки',
|
|
48
|
+
data: [[`Создаем заявку на пополнение...`]],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
footer: `<i>⏳ Прошло {{ ${Math.floor((Date.now() - startTime) / 1000)} }} сек.</i>`,
|
|
52
|
+
}),
|
|
53
|
+
parse_mode: 'HTML',
|
|
41
54
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
],
|
|
52
|
-
footer: `<i>⏳ Прошло {{ ${Math.floor((Date.now() - startTime) / 1000)} }} сек.</i>`,
|
|
53
|
-
}),
|
|
54
|
-
parse_mode: 'HTML',
|
|
55
|
-
});
|
|
56
|
-
}), 1000);
|
|
57
|
-
setTimeout(() => {
|
|
58
|
-
clearInterval(interval);
|
|
59
|
-
}, 300000);
|
|
60
|
-
}
|
|
61
|
-
let order;
|
|
62
|
-
if (method === 'card') {
|
|
63
|
-
for (const _method of ['qrcode', 'card']) {
|
|
64
|
-
method = _method;
|
|
65
|
-
order = yield config.API.post(`orders`, {
|
|
66
|
-
mirrorId: context.mammoth.mirror.mirror.id,
|
|
67
|
-
mammothId: context.user.id,
|
|
68
|
-
method,
|
|
69
|
-
amount: Number(deposit),
|
|
70
|
-
currency: config.currency,
|
|
71
|
-
})
|
|
72
|
-
.then((x) => x.data)
|
|
73
|
-
.catch(() => null);
|
|
74
|
-
if (order)
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
55
|
+
}), 1000);
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
clearInterval(interval);
|
|
58
|
+
}, 300000);
|
|
59
|
+
}
|
|
60
|
+
let order;
|
|
61
|
+
if (method === 'card') {
|
|
62
|
+
for (const _method of ['qrcode', 'card']) {
|
|
63
|
+
method = _method;
|
|
79
64
|
order = yield config.API.post(`orders`, {
|
|
80
65
|
mirrorId: context.mammoth.mirror.mirror.id,
|
|
81
66
|
mammothId: context.user.id,
|
|
@@ -85,49 +70,63 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
|
|
|
85
70
|
})
|
|
86
71
|
.then((x) => x.data)
|
|
87
72
|
.catch(() => null);
|
|
73
|
+
if (order)
|
|
74
|
+
break;
|
|
88
75
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
order = yield config.API.post(`orders`, {
|
|
79
|
+
mirrorId: context.mammoth.mirror.mirror.id,
|
|
80
|
+
mammothId: context.user.id,
|
|
81
|
+
method,
|
|
82
|
+
amount: Number(deposit),
|
|
83
|
+
currency: config.currency,
|
|
84
|
+
params: { walletId: coin },
|
|
85
|
+
})
|
|
86
|
+
.then((x) => x.data)
|
|
87
|
+
.catch(() => null);
|
|
88
|
+
}
|
|
89
|
+
//@ts-ignore
|
|
90
|
+
if (interval)
|
|
91
|
+
clearInterval(interval);
|
|
92
|
+
this.logger.log(`Запрос на пополнение: ${JSON.stringify(order, null, 2)}`);
|
|
93
|
+
if (!order) {
|
|
94
|
+
context.user.log(0, `Не удалось получить реквизиты для пополнения на сумму ${Number(deposit).toLocaleString('ru')} ${config.currency}`);
|
|
95
|
+
return context.sendFormatted({
|
|
96
|
+
photo: config.images.deposit,
|
|
97
|
+
header: '<b>❗️К сожалению, сейчас нет доступных реквизитов для оплаты.</b>',
|
|
98
|
+
footer: `<i>ℹ️ Вы можете попробовать чуть позже, воспользоваться другим способом оплаты, либо связаться с <a href="t.me/{{ ${config.support.username} }}">технической поддержкой</a>.</i>`,
|
|
99
|
+
}, {
|
|
100
|
+
reply_markup: {
|
|
101
|
+
inline_keyboard: [[{ text: '👩💻 Поддержка', url: `t.me/${config.support.username}` }]],
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (!order.isRepeat) {
|
|
106
|
+
yield context.user.log(0, `Запросил пополнение на ${Number(order.amount).toLocaleString('ru')} ${order.currency} ${order.currency !== 'RUB'
|
|
107
|
+
? `(${yield order.amount.convert({
|
|
108
|
+
from: order.currency,
|
|
109
|
+
to: 'RUB',
|
|
110
|
+
ceiled: true,
|
|
111
|
+
})})`
|
|
112
|
+
: ``}`, {
|
|
113
|
+
// prettier-ignore
|
|
114
|
+
message: order.card ?
|
|
115
|
+
`<b>💳 Реквизиты:</b> <code>${maskExceptLast4(order.card.requisites)}</code>\n` +
|
|
116
|
+
`<b>👩🏻💼 Получатель:</b> ${order.card.holder || '-'}`
|
|
117
|
+
: '',
|
|
118
|
+
keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
|
|
119
|
+
});
|
|
120
|
+
if (Number(deposit) !== Number(order.amount)) {
|
|
95
121
|
return context.sendFormatted({
|
|
96
122
|
photo: config.images.deposit,
|
|
97
|
-
header:
|
|
98
|
-
footer: `<i>ℹ️ Вы можете попробовать чуть позже, воспользоваться другим способом оплаты, либо связаться с <a href="t.me/{{ ${config.support.username} }}">технической поддержкой</a>.</i>`,
|
|
123
|
+
header: `<blockquote><b>ℹ️ Сумма пополнения стала выше</b></blockquote>\n\n<i>Для определения вашего пополнения в системе, Вам придется заплатить ${Number(order.amount).toLocaleString('ru')} ${order.currency.toUpperCase()}. Приносим свои извинения за неудобства</i>`,
|
|
99
124
|
}, {
|
|
100
125
|
reply_markup: {
|
|
101
|
-
inline_keyboard: [[{ text: '
|
|
126
|
+
inline_keyboard: [[{ text: '📖 Да, я все понял, продолжить', command: GetDepositOrder_command_1.GetDepositOrderCommand, payload: { orderId: order.id } }]],
|
|
102
127
|
},
|
|
103
128
|
});
|
|
104
129
|
}
|
|
105
|
-
if (!order.isRepeat) {
|
|
106
|
-
yield context.user.log(0, `Запросил пополнение на ${Number(order.amount).toLocaleString('ru')} ${order.currency} ${order.currency !== 'RUB'
|
|
107
|
-
? `(${yield order.amount.convert({
|
|
108
|
-
from: order.currency,
|
|
109
|
-
to: 'RUB',
|
|
110
|
-
ceiled: true,
|
|
111
|
-
})})`
|
|
112
|
-
: ``}`, {
|
|
113
|
-
// prettier-ignore
|
|
114
|
-
message: order.card ?
|
|
115
|
-
`<b>💳 Реквизиты:</b> <code>${maskExceptLast4(order.card.requisites)}</code>\n` +
|
|
116
|
-
`<b>👩🏻💼 Получатель:</b> ${order.card.holder || '-'}`
|
|
117
|
-
: '',
|
|
118
|
-
keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
|
|
119
|
-
});
|
|
120
|
-
if (Number(deposit) !== Number(order.amount)) {
|
|
121
|
-
return context.sendFormatted({
|
|
122
|
-
photo: config.images.deposit,
|
|
123
|
-
header: `<blockquote><b>ℹ️ Сумма пополнения стала выше</b></blockquote>\n\n<i>Для определения вашего пополнения в системе, Вам придется заплатить ${Number(order.amount).toLocaleString('ru')} ${order.currency.toUpperCase()}. Приносим свои извинения за неудобства</i>`,
|
|
124
|
-
}, {
|
|
125
|
-
reply_markup: {
|
|
126
|
-
inline_keyboard: [[{ text: '📖 Да, я все понял, продолжить', command: GetDepositOrder_command_1.GetDepositOrderCommand, payload: { orderId: order.id } }]],
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
130
|
setTimeout(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
132
131
|
var _a;
|
|
133
132
|
const neworder = yield config.API.get(`/orders/${order.id}`).then((x) => x.data);
|
|
@@ -139,31 +138,14 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
|
|
|
139
138
|
context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
|
|
140
139
|
context.sendFormatted({
|
|
141
140
|
photo: config.images.deposit,
|
|
142
|
-
header: `<blockquote>⚠️ Время на оплату истекло</blockquote>\n\n<i>Мы не получили пополнение по нашим реквизитам. Они больше недоступны для пополнения</i>\n\n<b>ℹ️ Если Вы оплатили, а система не определила Ваш перевод - <a href="t.me/${(_a = context.mirror.projectMirror.design.supportBot) === null || _a === void 0 ? void 0 : _a.username}">обратитесь в тех. поддержку</a></b>`,
|
|
141
|
+
header: `<blockquote><b>⚠️ Время на оплату истекло</b></blockquote>\n\n<i>Мы не получили пополнение по нашим реквизитам. Они больше недоступны для пополнения</i>\n\n<b>ℹ️ Если Вы оплатили, а система не определила Ваш перевод - <a href="t.me/${(_a = context.mirror.projectMirror.design.supportBot) === null || _a === void 0 ? void 0 : _a.username}">обратитесь в тех. поддержку</a></b>`,
|
|
143
142
|
reply_markup: {
|
|
144
143
|
inline_keyboard: [[{ text: '🔄 Проверить оплату', command: CheckPaidOrder_command_1.CheckPaidOrderCommand, payload: { orderId: order.id } }]],
|
|
145
144
|
},
|
|
146
145
|
});
|
|
147
146
|
}), new Date(order.expiresAt).getTime() - new Date().getTime());
|
|
148
|
-
context.redirect(GetDepositOrder_command_1.GetDepositOrderCommand, { orderId: order.id });
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
const wallets = (yield config.API.get('/crypto/wallets')).data.filter((x) => x.isActive);
|
|
152
|
-
context.sendFormatted({
|
|
153
|
-
photo: config.images.depositCrypto,
|
|
154
|
-
header: '<b>Создана заявка на оплату</b>',
|
|
155
|
-
body: [
|
|
156
|
-
{
|
|
157
|
-
title: 'ℹ️ Информация о реквизитах',
|
|
158
|
-
data: [
|
|
159
|
-
['Адрес кошелька', `{{ ${wallets.find((x) => x.name === coin).address} }}`],
|
|
160
|
-
['Криптовалюта', `{{ ${coin} }}`],
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
footer: '<i>Это Ваш постоянный адрес для пополнения.</i>',
|
|
165
|
-
});
|
|
166
147
|
}
|
|
148
|
+
context.redirect(GetDepositOrder_command_1.GetDepositOrderCommand, { orderId: order.id, repeat: order.isRepeat });
|
|
167
149
|
});
|
|
168
150
|
}
|
|
169
151
|
};
|
|
@@ -209,26 +191,45 @@ tslib_1.__decorate([
|
|
|
209
191
|
}
|
|
210
192
|
}))),
|
|
211
193
|
tslib_1.__param(2, (0, evogram_1.CommandArgument)('coin', (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, args, context }) {
|
|
212
|
-
if (
|
|
213
|
-
return value;
|
|
214
|
-
else if (args.method !== 'cryptoWallet')
|
|
194
|
+
if (args.method !== 'cryptoWallet')
|
|
215
195
|
return true;
|
|
196
|
+
else if (Number(value))
|
|
197
|
+
return value;
|
|
216
198
|
const config = Client_1.Client.config(context);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
199
|
+
if (!value) {
|
|
200
|
+
const wallets = yield config.API.get('/crypto/coins').then((x) => x.data);
|
|
201
|
+
context.sendFormatted({
|
|
202
|
+
header: '<b>🪙 Доступные криптовалюты для пополнения:</b>',
|
|
203
|
+
photo: config.images.depositCrypto,
|
|
204
|
+
}, {
|
|
205
|
+
reply_markup: {
|
|
206
|
+
inline_keyboard: wallets.map((x) => [
|
|
207
|
+
{
|
|
208
|
+
text: x.name,
|
|
209
|
+
command: DepositCommand,
|
|
210
|
+
payload: Object.assign(Object.assign({}, args), { coin: x.name }),
|
|
211
|
+
},
|
|
212
|
+
]),
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
const wallets = yield config.API.get(`/crypto/coins/${value}/wallets`).then((x) => x.data);
|
|
218
|
+
context.sendFormatted({
|
|
219
|
+
header: `<b>🪙 Выберите необходимую сеть для пополнения в ${value}</b>`,
|
|
220
|
+
photo: config.images.depositCrypto,
|
|
221
|
+
}, {
|
|
222
|
+
reply_markup: {
|
|
223
|
+
inline_keyboard: wallets.map((x) => [
|
|
224
|
+
{
|
|
225
|
+
text: x.network,
|
|
226
|
+
command: DepositCommand,
|
|
227
|
+
payload: Object.assign(Object.assign({}, args), { coin: x.id }),
|
|
228
|
+
},
|
|
229
|
+
]),
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
}
|
|
232
233
|
}))),
|
|
233
234
|
tslib_1.__param(3, (0, evogram_1.CommandArgument)({
|
|
234
235
|
name: 'deposit',
|
|
@@ -256,9 +257,7 @@ tslib_1.__decorate([
|
|
|
256
257
|
error: error === null || error === void 0 ? void 0 : error.message,
|
|
257
258
|
})).text;
|
|
258
259
|
}),
|
|
259
|
-
}, (0, evogram_1.numberValidator)({ allowFloat: true, min: 0 }), (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, context
|
|
260
|
-
if (args.method === 'cryptoWallet')
|
|
261
|
-
return 0;
|
|
260
|
+
}, (0, evogram_1.numberValidator)({ allowFloat: true, min: 0 }), (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, context }) {
|
|
262
261
|
const config = Client_1.Client.config(context);
|
|
263
262
|
const maxDeposit = yield config.API.get('/config/maxDepositInService').then((x) => x.data.value);
|
|
264
263
|
const depositAmount = yield value.convert({ from: config.currency, to: 'RUB' });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from 'evogram';
|
|
2
2
|
import { CommandContext } from 'evogram/lib/migrated';
|
|
3
3
|
export declare class GetDepositOrderCommand extends Command {
|
|
4
|
-
execute(context: CommandContext, orderId: string): Promise<void>;
|
|
4
|
+
execute(context: CommandContext, orderId: string, repeat?: boolean): Promise<void>;
|
|
5
5
|
}
|
|
@@ -8,7 +8,7 @@ const Client_1 = require("../../Client");
|
|
|
8
8
|
const CheckPaidOrder_command_1 = require("./CheckPaidOrder.command");
|
|
9
9
|
const SendCheque_command_1 = require("./SendCheque.command");
|
|
10
10
|
let GetDepositOrderCommand = class GetDepositOrderCommand extends evogram_1.Command {
|
|
11
|
-
execute(context, orderId) {
|
|
11
|
+
execute(context, orderId, repeat) {
|
|
12
12
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
13
|
const config = Client_1.Client.config(context);
|
|
14
14
|
const order = yield config.API.get(`/orders/${orderId}`)
|
|
@@ -48,7 +48,7 @@ let GetDepositOrderCommand = class GetDepositOrderCommand extends evogram_1.Comm
|
|
|
48
48
|
case 'card':
|
|
49
49
|
message = yield context.sendFormatted({
|
|
50
50
|
photo: config.images.deposit,
|
|
51
|
-
header:
|
|
51
|
+
header: repeat ? '<b>❗️У вас уже есть заявка на пополнение, сначала оплатите ёё</b>' : '<b>Создана заявка на оплату</b>',
|
|
52
52
|
body: [
|
|
53
53
|
{
|
|
54
54
|
title: 'ℹ️ Информация о реквизитах',
|
|
@@ -88,6 +88,27 @@ let GetDepositOrderCommand = class GetDepositOrderCommand extends evogram_1.Comm
|
|
|
88
88
|
],
|
|
89
89
|
},
|
|
90
90
|
});
|
|
91
|
+
case 'crypto':
|
|
92
|
+
message = yield context.sendFormatted({
|
|
93
|
+
photo: config.images.depositCrypto,
|
|
94
|
+
// prettier-ignore
|
|
95
|
+
header: '<blockquote><b>📥 Создана заявка на пополнение</b></blockquote>\n\n' +
|
|
96
|
+
`<i>— Сумма пополнения: ${order.amount} ${order.currency}</i>\n` +
|
|
97
|
+
`<i>— Курс: ${order.currency} ≈ ${order.crypto.rate} ${order.crypto.currency}</i>\n\n` +
|
|
98
|
+
`<i>— Сеть пополнения: ${order.crypto.wallet.currency.name} / ${order.crypto.wallet.network}</i>\n` +
|
|
99
|
+
`<i>— Время пополнения: до ${new Date(order.expiresAt).toLocaleString('ru')} по МКС</i>\n\n` +
|
|
100
|
+
`<b>${order.crypto.wallet.address}</b>`,
|
|
101
|
+
}, {
|
|
102
|
+
reply_markup: {
|
|
103
|
+
inline_keyboard: [
|
|
104
|
+
[{ text: '🔗 Скопировать адрес', copy_text: { text: order.crypto.wallet.address } }],
|
|
105
|
+
[
|
|
106
|
+
{ text: '🔄 Проверить оплату', command: CheckPaidOrder_command_1.CheckPaidOrderCommand, payload: { orderId: order.id } },
|
|
107
|
+
{ text: '✅ Я оплатил', command: SendCheque_command_1.SendChequeCommand, payload: { orderId: order.id } },
|
|
108
|
+
],
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
});
|
|
91
112
|
}
|
|
92
113
|
yield this.client.database.config.set(`order${orderId}`, { chatId: context.chat.id, messageId: message.id });
|
|
93
114
|
});
|
|
@@ -96,8 +117,9 @@ let GetDepositOrderCommand = class GetDepositOrderCommand extends evogram_1.Comm
|
|
|
96
117
|
exports.GetDepositOrderCommand = GetDepositOrderCommand;
|
|
97
118
|
tslib_1.__decorate([
|
|
98
119
|
tslib_1.__param(1, (0, evogram_1.CommandArgument)('orderId')),
|
|
120
|
+
tslib_1.__param(2, (0, evogram_1.CommandArgument)('repeat?')),
|
|
99
121
|
tslib_1.__metadata("design:type", Function),
|
|
100
|
-
tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String]),
|
|
122
|
+
tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String, Boolean]),
|
|
101
123
|
tslib_1.__metadata("design:returntype", Promise)
|
|
102
124
|
], GetDepositOrderCommand.prototype, "execute", null);
|
|
103
125
|
exports.GetDepositOrderCommand = GetDepositOrderCommand = tslib_1.__decorate([
|
package/package.json
CHANGED
|
@@ -75,29 +75,50 @@ export class DepositCommand extends Command {
|
|
|
75
75
|
method: string,
|
|
76
76
|
|
|
77
77
|
@CommandArgument('coin', async ({ value, args, context }) => {
|
|
78
|
-
if (
|
|
79
|
-
else if (
|
|
78
|
+
if (args.method !== 'cryptoWallet') return true;
|
|
79
|
+
else if (Number(value)) return value;
|
|
80
80
|
|
|
81
81
|
const config = Client.config(context);
|
|
82
|
-
const wallets = await config.API.get('/crypto/wallets').then((x) => x.data.filter((x: any) => x.isActive));
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
reply_markup: {
|
|
91
|
-
inline_keyboard: wallets.map((x: any) => [
|
|
92
|
-
{
|
|
93
|
-
text: x.name,
|
|
94
|
-
command: DepositCommand,
|
|
95
|
-
payload: { ...args, coin: x.name },
|
|
96
|
-
},
|
|
97
|
-
]),
|
|
83
|
+
if (!value) {
|
|
84
|
+
const wallets = await config.API.get('/crypto/coins').then((x) => x.data);
|
|
85
|
+
context.sendFormatted(
|
|
86
|
+
{
|
|
87
|
+
header: '<b>🪙 Доступные криптовалюты для пополнения:</b>',
|
|
88
|
+
photo: config.images.depositCrypto,
|
|
98
89
|
},
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
{
|
|
91
|
+
reply_markup: {
|
|
92
|
+
inline_keyboard: wallets.map((x: any) => [
|
|
93
|
+
{
|
|
94
|
+
text: x.name,
|
|
95
|
+
command: DepositCommand,
|
|
96
|
+
payload: { ...args, coin: x.name },
|
|
97
|
+
},
|
|
98
|
+
]),
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
} else {
|
|
103
|
+
const wallets = await config.API.get(`/crypto/coins/${value}/wallets`).then((x) => x.data);
|
|
104
|
+
context.sendFormatted(
|
|
105
|
+
{
|
|
106
|
+
header: `<b>🪙 Выберите необходимую сеть для пополнения в ${value}</b>`,
|
|
107
|
+
photo: config.images.depositCrypto,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
reply_markup: {
|
|
111
|
+
inline_keyboard: wallets.map((x: any) => [
|
|
112
|
+
{
|
|
113
|
+
text: x.network,
|
|
114
|
+
command: DepositCommand,
|
|
115
|
+
payload: { ...args, coin: x.id },
|
|
116
|
+
},
|
|
117
|
+
]),
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
101
122
|
})
|
|
102
123
|
coin: string | undefined,
|
|
103
124
|
|
|
@@ -133,8 +154,7 @@ export class DepositCommand extends Command {
|
|
|
133
154
|
},
|
|
134
155
|
},
|
|
135
156
|
numberValidator({ allowFloat: true, min: 0 }),
|
|
136
|
-
async ({ value, context
|
|
137
|
-
if (args.method === 'cryptoWallet') return 0;
|
|
157
|
+
async ({ value, context }) => {
|
|
138
158
|
const config = Client.config(context);
|
|
139
159
|
|
|
140
160
|
const maxDeposit = await config.API.get('/config/maxDepositInService').then((x) => x.data.value);
|
|
@@ -163,58 +183,44 @@ export class DepositCommand extends Command {
|
|
|
163
183
|
const config = Client.config(context);
|
|
164
184
|
let interval: NodeJS.Timeout;
|
|
165
185
|
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
});
|
|
186
|
+
if (['card', 'qrcode'].includes(method)) {
|
|
187
|
+
const message = await context.sendFormatted({
|
|
188
|
+
photo: config.images.deposit,
|
|
189
|
+
body: [
|
|
190
|
+
{
|
|
191
|
+
title: 'ℹ️ Подождите, идет обработка заявки',
|
|
192
|
+
data: [['Создаем заявку на пополнение...']],
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
});
|
|
177
196
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
setTimeout(() => {
|
|
195
|
-
clearInterval(interval);
|
|
196
|
-
}, 300_000);
|
|
197
|
-
}
|
|
197
|
+
const startTime = Date.now();
|
|
198
|
+
interval = setInterval(async () => {
|
|
199
|
+
await message.edit({
|
|
200
|
+
text: formatMessage({
|
|
201
|
+
body: [
|
|
202
|
+
{
|
|
203
|
+
title: 'ℹ️ Подождите, идет обработка заявки',
|
|
204
|
+
data: [[`Создаем заявку на пополнение...`]],
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
footer: `<i>⏳ Прошло {{ ${Math.floor((Date.now() - startTime) / 1000)} }} сек.</i>`,
|
|
208
|
+
}),
|
|
209
|
+
parse_mode: 'HTML',
|
|
210
|
+
});
|
|
211
|
+
}, 1000);
|
|
198
212
|
|
|
199
|
-
|
|
213
|
+
setTimeout(() => {
|
|
214
|
+
clearInterval(interval);
|
|
215
|
+
}, 300_000);
|
|
216
|
+
}
|
|
200
217
|
|
|
201
|
-
|
|
202
|
-
for (const _method of ['qrcode', 'card']) {
|
|
203
|
-
method = _method;
|
|
218
|
+
let order: any;
|
|
204
219
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
method,
|
|
209
|
-
amount: Number(deposit),
|
|
210
|
-
currency: config.currency,
|
|
211
|
-
})
|
|
212
|
-
.then((x) => x.data)
|
|
213
|
-
.catch(() => null);
|
|
220
|
+
if (method === 'card') {
|
|
221
|
+
for (const _method of ['qrcode', 'card']) {
|
|
222
|
+
method = _method;
|
|
214
223
|
|
|
215
|
-
if (order) break;
|
|
216
|
-
}
|
|
217
|
-
} else {
|
|
218
224
|
order = await config.API.post(`orders`, {
|
|
219
225
|
mirrorId: context.mammoth.mirror.mirror.id,
|
|
220
226
|
mammothId: context.user.id,
|
|
@@ -224,68 +230,81 @@ export class DepositCommand extends Command {
|
|
|
224
230
|
})
|
|
225
231
|
.then((x) => x.data)
|
|
226
232
|
.catch(() => null);
|
|
233
|
+
|
|
234
|
+
if (order) break;
|
|
227
235
|
}
|
|
236
|
+
} else {
|
|
237
|
+
order = await config.API.post(`orders`, {
|
|
238
|
+
mirrorId: context.mammoth.mirror.mirror.id,
|
|
239
|
+
mammothId: context.user.id,
|
|
240
|
+
method,
|
|
241
|
+
amount: Number(deposit),
|
|
242
|
+
currency: config.currency,
|
|
243
|
+
params: { walletId: coin },
|
|
244
|
+
})
|
|
245
|
+
.then((x) => x.data)
|
|
246
|
+
.catch(() => null);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
//@ts-ignore
|
|
250
|
+
if (interval) clearInterval(interval);
|
|
251
|
+
this.logger.log(`Запрос на пополнение: ${JSON.stringify(order, null, 2)}`);
|
|
252
|
+
|
|
253
|
+
if (!order) {
|
|
254
|
+
context.user.log(0, `Не удалось получить реквизиты для пополнения на сумму ${Number(deposit).toLocaleString('ru')} ${config.currency}`);
|
|
255
|
+
return context.sendFormatted(
|
|
256
|
+
{
|
|
257
|
+
photo: config.images.deposit,
|
|
258
|
+
header: '<b>❗️К сожалению, сейчас нет доступных реквизитов для оплаты.</b>',
|
|
259
|
+
footer: `<i>ℹ️ Вы можете попробовать чуть позже, воспользоваться другим способом оплаты, либо связаться с <a href="t.me/{{ ${config.support.username} }}">технической поддержкой</a>.</i>`,
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
reply_markup: {
|
|
263
|
+
inline_keyboard: [[{ text: '👩💻 Поддержка', url: `t.me/${config.support.username}` }]],
|
|
264
|
+
},
|
|
265
|
+
}
|
|
266
|
+
);
|
|
267
|
+
}
|
|
228
268
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
269
|
+
if (!order.isRepeat) {
|
|
270
|
+
await context.user.log(
|
|
271
|
+
0,
|
|
272
|
+
`Запросил пополнение на ${Number(order.amount).toLocaleString('ru')} ${order.currency} ${
|
|
273
|
+
order.currency !== 'RUB'
|
|
274
|
+
? `(${await order.amount.convert({
|
|
275
|
+
from: order.currency,
|
|
276
|
+
to: 'RUB',
|
|
277
|
+
ceiled: true,
|
|
278
|
+
})})`
|
|
279
|
+
: ``
|
|
280
|
+
}`,
|
|
281
|
+
{
|
|
282
|
+
// prettier-ignore
|
|
283
|
+
message:
|
|
284
|
+
order.card ?
|
|
285
|
+
`<b>💳 Реквизиты:</b> <code>${maskExceptLast4(order.card.requisites)}</code>\n` +
|
|
286
|
+
`<b>👩🏻💼 Получатель:</b> ${order.card.holder || '-'}`
|
|
287
|
+
: '',
|
|
288
|
+
keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
|
|
289
|
+
}
|
|
290
|
+
);
|
|
232
291
|
|
|
233
|
-
if (
|
|
234
|
-
context.user.log(0, `Не удалось получить реквизиты для пополнения на сумму ${Number(deposit).toLocaleString('ru')} ${config.currency}`);
|
|
292
|
+
if (Number(deposit) !== Number(order.amount)) {
|
|
235
293
|
return context.sendFormatted(
|
|
236
294
|
{
|
|
237
295
|
photo: config.images.deposit,
|
|
238
|
-
header:
|
|
239
|
-
|
|
296
|
+
header: `<blockquote><b>ℹ️ Сумма пополнения стала выше</b></blockquote>\n\n<i>Для определения вашего пополнения в системе, Вам придется заплатить ${Number(
|
|
297
|
+
order.amount
|
|
298
|
+
).toLocaleString('ru')} ${order.currency.toUpperCase()}. Приносим свои извинения за неудобства</i>`,
|
|
240
299
|
},
|
|
241
300
|
{
|
|
242
301
|
reply_markup: {
|
|
243
|
-
inline_keyboard: [[{ text: '
|
|
302
|
+
inline_keyboard: [[{ text: '📖 Да, я все понял, продолжить', command: GetDepositOrderCommand, payload: { orderId: order.id } }]],
|
|
244
303
|
},
|
|
245
304
|
}
|
|
246
305
|
);
|
|
247
306
|
}
|
|
248
307
|
|
|
249
|
-
if (!order.isRepeat) {
|
|
250
|
-
await context.user.log(
|
|
251
|
-
0,
|
|
252
|
-
`Запросил пополнение на ${Number(order.amount).toLocaleString('ru')} ${order.currency} ${
|
|
253
|
-
order.currency !== 'RUB'
|
|
254
|
-
? `(${await order.amount.convert({
|
|
255
|
-
from: order.currency,
|
|
256
|
-
to: 'RUB',
|
|
257
|
-
ceiled: true,
|
|
258
|
-
})})`
|
|
259
|
-
: ``
|
|
260
|
-
}`,
|
|
261
|
-
{
|
|
262
|
-
// prettier-ignore
|
|
263
|
-
message:
|
|
264
|
-
order.card ?
|
|
265
|
-
`<b>💳 Реквизиты:</b> <code>${maskExceptLast4(order.card.requisites)}</code>\n` +
|
|
266
|
-
`<b>👩🏻💼 Получатель:</b> ${order.card.holder || '-'}`
|
|
267
|
-
: '',
|
|
268
|
-
keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
|
|
269
|
-
}
|
|
270
|
-
);
|
|
271
|
-
|
|
272
|
-
if (Number(deposit) !== Number(order.amount)) {
|
|
273
|
-
return context.sendFormatted(
|
|
274
|
-
{
|
|
275
|
-
photo: config.images.deposit,
|
|
276
|
-
header: `<blockquote><b>ℹ️ Сумма пополнения стала выше</b></blockquote>\n\n<i>Для определения вашего пополнения в системе, Вам придется заплатить ${Number(
|
|
277
|
-
order.amount
|
|
278
|
-
).toLocaleString('ru')} ${order.currency.toUpperCase()}. Приносим свои извинения за неудобства</i>`,
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
reply_markup: {
|
|
282
|
-
inline_keyboard: [[{ text: '📖 Да, я все понял, продолжить', command: GetDepositOrderCommand, payload: { orderId: order.id } }]],
|
|
283
|
-
},
|
|
284
|
-
}
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
308
|
setTimeout(async () => {
|
|
290
309
|
const neworder = await config.API.get(`/orders/${order.id}`).then((x) => x.data);
|
|
291
310
|
if (['paid', 'fakepaid'].includes(neworder.status) || neworder.cheque) return;
|
|
@@ -296,31 +315,14 @@ export class DepositCommand extends Command {
|
|
|
296
315
|
context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
|
|
297
316
|
context.sendFormatted({
|
|
298
317
|
photo: config.images.deposit,
|
|
299
|
-
header: `<blockquote>⚠️ Время на оплату истекло</blockquote>\n\n<i>Мы не получили пополнение по нашим реквизитам. Они больше недоступны для пополнения</i>\n\n<b>ℹ️ Если Вы оплатили, а система не определила Ваш перевод - <a href="t.me/${context.mirror.projectMirror.design.supportBot?.username}">обратитесь в тех. поддержку</a></b>`,
|
|
318
|
+
header: `<blockquote><b>⚠️ Время на оплату истекло</b></blockquote>\n\n<i>Мы не получили пополнение по нашим реквизитам. Они больше недоступны для пополнения</i>\n\n<b>ℹ️ Если Вы оплатили, а система не определила Ваш перевод - <a href="t.me/${context.mirror.projectMirror.design.supportBot?.username}">обратитесь в тех. поддержку</a></b>`,
|
|
300
319
|
reply_markup: {
|
|
301
320
|
inline_keyboard: [[{ text: '🔄 Проверить оплату', command: CheckPaidOrderCommand, payload: { orderId: order.id } }]],
|
|
302
321
|
},
|
|
303
322
|
});
|
|
304
323
|
}, new Date(order.expiresAt).getTime() - new Date().getTime());
|
|
305
|
-
|
|
306
|
-
context.redirect(GetDepositOrderCommand, { orderId: order.id });
|
|
307
|
-
} else {
|
|
308
|
-
const wallets = (await config.API.get('/crypto/wallets')).data.filter((x: any) => x.isActive);
|
|
309
|
-
|
|
310
|
-
context.sendFormatted({
|
|
311
|
-
photo: config.images.depositCrypto,
|
|
312
|
-
header: '<b>Создана заявка на оплату</b>',
|
|
313
|
-
body: [
|
|
314
|
-
{
|
|
315
|
-
title: 'ℹ️ Информация о реквизитах',
|
|
316
|
-
data: [
|
|
317
|
-
['Адрес кошелька', `{{ ${wallets.find((x: any) => x.name === coin).address} }}`],
|
|
318
|
-
['Криптовалюта', `{{ ${coin} }}`],
|
|
319
|
-
],
|
|
320
|
-
},
|
|
321
|
-
],
|
|
322
|
-
footer: '<i>Это Ваш постоянный адрес для пополнения.</i>',
|
|
323
|
-
});
|
|
324
324
|
}
|
|
325
|
+
|
|
326
|
+
context.redirect(GetDepositOrderCommand, { orderId: order.id, repeat: order.isRepeat });
|
|
325
327
|
}
|
|
326
328
|
}
|
|
@@ -6,7 +6,7 @@ import { SendChequeCommand } from './SendCheque.command';
|
|
|
6
6
|
|
|
7
7
|
@CommandD({ name: 'getDepositOrder', backButton: 'К пополнению' })
|
|
8
8
|
export class GetDepositOrderCommand extends Command {
|
|
9
|
-
public async execute(context: CommandContext, @CommandArgument('orderId') orderId: string) {
|
|
9
|
+
public async execute(context: CommandContext, @CommandArgument('orderId') orderId: string, @CommandArgument('repeat?') repeat?: boolean) {
|
|
10
10
|
const config = Client.config(context);
|
|
11
11
|
const order = await config.API.get(`/orders/${orderId}`)
|
|
12
12
|
.then((x) => x.data)
|
|
@@ -51,7 +51,7 @@ export class GetDepositOrderCommand extends Command {
|
|
|
51
51
|
message = await context.sendFormatted(
|
|
52
52
|
{
|
|
53
53
|
photo: config.images.deposit,
|
|
54
|
-
header:
|
|
54
|
+
header: repeat ? '<b>❗️У вас уже есть заявка на пополнение, сначала оплатите ёё</b>' : '<b>Создана заявка на оплату</b>',
|
|
55
55
|
body: [
|
|
56
56
|
{
|
|
57
57
|
title: 'ℹ️ Информация о реквизитах',
|
|
@@ -96,6 +96,34 @@ export class GetDepositOrderCommand extends Command {
|
|
|
96
96
|
},
|
|
97
97
|
}
|
|
98
98
|
);
|
|
99
|
+
case 'crypto':
|
|
100
|
+
message = await context.sendFormatted(
|
|
101
|
+
{
|
|
102
|
+
photo: config.images.depositCrypto,
|
|
103
|
+
// prettier-ignore
|
|
104
|
+
header:
|
|
105
|
+
'<blockquote><b>📥 Создана заявка на пополнение</b></blockquote>\n\n' +
|
|
106
|
+
|
|
107
|
+
`<i>— Сумма пополнения: ${order.amount} ${order.currency}</i>\n` +
|
|
108
|
+
`<i>— Курс: ${order.currency} ≈ ${order.crypto.rate} ${order.crypto.currency}</i>\n\n` +
|
|
109
|
+
|
|
110
|
+
`<i>— Сеть пополнения: ${order.crypto.wallet.currency.name} / ${order.crypto.wallet.network}</i>\n` +
|
|
111
|
+
`<i>— Время пополнения: до ${new Date(order.expiresAt).toLocaleString('ru')} по МКС</i>\n\n` +
|
|
112
|
+
|
|
113
|
+
`<b>${order.crypto.wallet.address}</b>`,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
reply_markup: {
|
|
117
|
+
inline_keyboard: [
|
|
118
|
+
[{ text: '🔗 Скопировать адрес', copy_text: { text: order.crypto.wallet.address } }],
|
|
119
|
+
[
|
|
120
|
+
{ text: '🔄 Проверить оплату', command: CheckPaidOrderCommand, payload: { orderId: order.id } },
|
|
121
|
+
{ text: '✅ Я оплатил', command: SendChequeCommand, payload: { orderId: order.id } },
|
|
122
|
+
],
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
);
|
|
99
127
|
}
|
|
100
128
|
|
|
101
129
|
await this.client.database.config.set(`order${orderId}`, { chatId: context.chat.id, messageId: message.id });
|