nexushub-commands 1.4.2 → 1.5.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.
@@ -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 (method !== 'cryptoWallet') {
32
- if (['card', 'qrcode'].includes(method)) {
33
- const message = yield context.sendFormatted({
34
- photo: config.images.deposit,
35
- body: [
36
- {
37
- title: 'ℹ️ Подождите, идет обработка заявки',
38
- data: [['Создаем заявку на пополнение...']],
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
- const startTime = Date.now();
43
- interval = setInterval(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
44
- yield message.edit({
45
- text: (0, formatMessage_1.formatMessage)({
46
- body: [
47
- {
48
- title: 'ℹ️ Подождите, идет обработка заявки',
49
- data: [[`Создаем заявку на пополнение...`]],
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,85 +70,82 @@ 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
- //@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}`);
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: '<b>❗️К сожалению, сейчас нет доступных реквизитов для оплаты.</b>',
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: '👩‍💻 Поддержка', url: `t.me/${config.support.username}` }]],
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
- setTimeout(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
131
- var _a;
132
- const neworder = yield config.API.get(`/orders/${order.id}`).then((x) => x.data);
133
- if (['paid', 'fakepaid'].includes(neworder.status) || neworder.cheque)
134
- return;
135
- const msgInfo = yield context.client.database.config.get(`order${order.id}`);
136
- if (!msgInfo)
137
- return;
138
- context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
139
- context.sendFormatted({
140
- photo: config.images.deposit,
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>`,
142
- reply_markup: {
143
- inline_keyboard: [[{ text: '🔄 Проверить оплату', command: CheckPaidOrder_command_1.CheckPaidOrderCommand, payload: { orderId: order.id } }]],
144
- },
145
- });
146
- }), new Date(order.expiresAt).getTime() - new Date().getTime());
147
- }
148
- context.redirect(GetDepositOrder_command_1.GetDepositOrderCommand, { orderId: order.id, repeat: order.isRepeat });
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
- ],
130
+ setTimeout(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
131
+ var _a;
132
+ const neworder = yield config.API.get(`/orders/${order.id}`).then((x) => x.data);
133
+ if (['paid', 'fakepaid'].includes(neworder.status) || neworder.cheque)
134
+ return;
135
+ const msgInfo = yield context.client.database.config.get(`order${order.id}`);
136
+ if (!msgInfo)
137
+ return;
138
+ context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
139
+ context.sendFormatted({
140
+ photo: config.images.deposit,
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>`,
142
+ reply_markup: {
143
+ inline_keyboard: [[{ text: '🔄 Проверить оплату', command: CheckPaidOrder_command_1.CheckPaidOrderCommand, payload: { orderId: order.id } }]],
162
144
  },
163
- ],
164
- footer: '<i>Это Ваш постоянный адрес для пополнения.</i>',
165
- });
145
+ });
146
+ }), new Date(order.expiresAt).getTime() - new Date().getTime());
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 (value)
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
- const wallets = yield config.API.get('/crypto/wallets').then((x) => x.data.filter((x) => x.isActive));
218
- context.sendFormatted({
219
- header: '<b>🪙 Доступные криптовалюты для пополнения:</b>',
220
- photo: config.images.depositCrypto,
221
- }, {
222
- reply_markup: {
223
- inline_keyboard: wallets.map((x) => [
224
- {
225
- text: x.name,
226
- command: DepositCommand,
227
- payload: Object.assign(Object.assign({}, args), { coin: x.name }),
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.coin }),
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, args }) {
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' });
@@ -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>— Курс: 1 ${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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -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 (value) return value;
79
- else if (args.method !== 'cryptoWallet') return true;
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
- context.sendFormatted(
85
- {
86
- header: '<b>🪙 Доступные криптовалюты для пополнения:</b>',
87
- photo: config.images.depositCrypto,
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.coin },
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, args }) => {
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 (method !== 'cryptoWallet') {
167
- if (['card', 'qrcode'].includes(method)) {
168
- const message = await context.sendFormatted({
169
- photo: config.images.deposit,
170
- body: [
171
- {
172
- title: 'ℹ️ Подождите, идет обработка заявки',
173
- data: [['Создаем заявку на пополнение...']],
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
- const startTime = Date.now();
179
- interval = setInterval(async () => {
180
- await message.edit({
181
- text: formatMessage({
182
- body: [
183
- {
184
- title: 'ℹ️ Подождите, идет обработка заявки',
185
- data: [[`Создаем заявку на пополнение...`]],
186
- },
187
- ],
188
- footer: `<i>⏳ Прошло {{ ${Math.floor((Date.now() - startTime) / 1000)} }} сек.</i>`,
189
- }),
190
- parse_mode: 'HTML',
191
- });
192
- }, 1000);
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
- let order: any;
213
+ setTimeout(() => {
214
+ clearInterval(interval);
215
+ }, 300_000);
216
+ }
200
217
 
201
- if (method === 'card') {
202
- for (const _method of ['qrcode', 'card']) {
203
- method = _method;
218
+ let order: any;
204
219
 
205
- order = await config.API.post(`orders`, {
206
- mirrorId: context.mammoth.mirror.mirror.id,
207
- mammothId: context.user.id,
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,103 +230,99 @@ 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
+ }
228
248
 
229
- //@ts-ignore
230
- if (interval) clearInterval(interval);
231
- this.logger.log(`Запрос на пополнение: ${JSON.stringify(order, null, 2)}`);
249
+ //@ts-ignore
250
+ if (interval) clearInterval(interval);
251
+ this.logger.log(`Запрос на пополнение: ${JSON.stringify(order, null, 2)}`);
232
252
 
233
- if (!order) {
234
- context.user.log(0, `Не удалось получить реквизиты для пополнения на сумму ${Number(deposit).toLocaleString('ru')} ${config.currency}`);
235
- return context.sendFormatted(
236
- {
237
- photo: config.images.deposit,
238
- header: '<b>❗️К сожалению, сейчас нет доступных реквизитов для оплаты.</b>',
239
- footer: `<i>ℹ️ Вы можете попробовать чуть позже, воспользоваться другим способом оплаты, либо связаться с <a href="t.me/{{ ${config.support.username} }}">технической поддержкой</a>.</i>`,
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}` }]],
240
264
  },
241
- {
242
- reply_markup: {
243
- inline_keyboard: [[{ text: '👩‍💻 Поддержка', url: `t.me/${config.support.username}` }]],
244
- },
245
- }
246
- );
247
- }
265
+ }
266
+ );
267
+ }
248
268
 
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:
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:
264
284
  order.card ?
265
285
  `<b>💳 Реквизиты:</b> <code>${maskExceptLast4(order.card.requisites)}</code>\n` +
266
286
  `<b>👩🏻‍💼 Получатель:</b> ${order.card.holder || '-'}`
267
287
  : '',
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
- );
288
+ keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
286
289
  }
290
+ );
287
291
 
288
- setTimeout(async () => {
289
- const neworder = await config.API.get(`/orders/${order.id}`).then((x) => x.data);
290
- if (['paid', 'fakepaid'].includes(neworder.status) || neworder.cheque) return;
291
-
292
- const msgInfo = await context.client.database.config.get(`order${order.id}`);
293
- if (!msgInfo) return;
294
-
295
- context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
296
- context.sendFormatted({
292
+ if (Number(deposit) !== Number(order.amount)) {
293
+ return context.sendFormatted(
294
+ {
297
295
  photo: config.images.deposit,
298
- header: `<blockquote><b>⚠️ Время на оплату истекло</b></blockquote>\n\n<i>Мы не получили пополнение по нашим реквизитам. Они больше недоступны для пополнения</i>\n\n<b>ℹ️ Если Вы оплатили, а система не определила Ваш перевод - <a href="t.me/${context.mirror.projectMirror.design.supportBot?.username}">обратитесь в тех. поддержку</a></b>`,
296
+ header: `<blockquote><b>ℹ️ Сумма пополнения стала выше</b></blockquote>\n\n<i>Для определения вашего пополнения в системе, Вам придется заплатить ${Number(
297
+ order.amount
298
+ ).toLocaleString('ru')} ${order.currency.toUpperCase()}. Приносим свои извинения за неудобства</i>`,
299
+ },
300
+ {
299
301
  reply_markup: {
300
- inline_keyboard: [[{ text: '🔄 Проверить оплату', command: CheckPaidOrderCommand, payload: { orderId: order.id } }]],
302
+ inline_keyboard: [[{ text: '📖 Да, я все понял, продолжить', command: GetDepositOrderCommand, payload: { orderId: order.id } }]],
301
303
  },
302
- });
303
- }, new Date(order.expiresAt).getTime() - new Date().getTime());
304
+ }
305
+ );
304
306
  }
305
307
 
306
- context.redirect(GetDepositOrderCommand, { orderId: order.id, repeat: order.isRepeat });
307
- } else {
308
- const wallets = (await config.API.get('/crypto/wallets')).data.filter((x: any) => x.isActive);
308
+ setTimeout(async () => {
309
+ const neworder = await config.API.get(`/orders/${order.id}`).then((x) => x.data);
310
+ if (['paid', 'fakepaid'].includes(neworder.status) || neworder.cheque) return;
309
311
 
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
- ],
312
+ const msgInfo = await context.client.database.config.get(`order${order.id}`);
313
+ if (!msgInfo) return;
314
+
315
+ context.client.api.deleteMessage({ chat_id: msgInfo.value.chatId, message_id: msgInfo.value.messageId });
316
+ context.sendFormatted({
317
+ photo: config.images.deposit,
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>`,
319
+ reply_markup: {
320
+ inline_keyboard: [[{ text: '🔄 Проверить оплату', command: CheckPaidOrderCommand, payload: { orderId: order.id } }]],
320
321
  },
321
- ],
322
- footer: '<i>Это Ваш постоянный адрес для пополнения.</i>',
323
- });
322
+ });
323
+ }, new Date(order.expiresAt).getTime() - new Date().getTime());
324
324
  }
325
+
326
+ context.redirect(GetDepositOrderCommand, { orderId: order.id, repeat: order.isRepeat });
325
327
  }
326
328
  }
@@ -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>— Курс: 1 ${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 });