nexushub-commands 2.0.10 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/deposit/Deposit.command.js +2 -0
- package/lib/commands/registration/Registration.command.js +1 -1
- package/lib/commands/withdrawal/AdminWithdrawal.command.d.ts +1 -1
- package/lib/commands/withdrawal/AdminWithdrawal.command.js +4 -3
- package/lib/commands/withdrawal/Withdrawal.command.d.ts +1 -1
- package/lib/commands/withdrawal/Withdrawal.command.js +25 -14
- package/lib/shared-commands/ParserSharedCommands.service.js +0 -3
- package/package.json +1 -1
- package/src/commands/deposit/Deposit.command.ts +3 -0
- package/src/commands/registration/Registration.command.ts +1 -1
- package/src/commands/withdrawal/AdminWithdrawal.command.ts +2 -2
- package/src/commands/withdrawal/Withdrawal.command.ts +35 -17
- package/src/shared-commands/ParserSharedCommands.service.ts +0 -5
|
@@ -107,6 +107,8 @@ let DepositCommand = class DepositCommand extends evogram_1.Command {
|
|
|
107
107
|
`<b>👩🏻💼 Получатель:</b> ${order.card.holder || '-'}`
|
|
108
108
|
: '',
|
|
109
109
|
keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
|
|
110
|
+
}, {
|
|
111
|
+
thumbnail: 'https://i.ibb.co/MDrGBbQR/image.png',
|
|
110
112
|
});
|
|
111
113
|
if (Number(deposit) !== Number(order.amount) && method !== 'cryptoWallet') {
|
|
112
114
|
return context.sendFormatted({
|
|
@@ -86,7 +86,7 @@ let RegistrationCommand = RegistrationCommand_1 = class RegistrationCommand exte
|
|
|
86
86
|
}).then(({ data }) => data.reg);
|
|
87
87
|
if (result) {
|
|
88
88
|
this.logger.log(`Первая регистрация мамонта, отправляем лог`);
|
|
89
|
-
user.log(0, `Мамонт зарегистрировался в
|
|
89
|
+
user.log(0, `Мамонт зарегистрировался в боте`, undefined, { thumbnail: 'https://i.ibb.co/cKccjJqx/image.png' });
|
|
90
90
|
user.userDB.payload.queryCurrency = true;
|
|
91
91
|
user.userDB.payload.queryLanguage = true;
|
|
92
92
|
}
|
|
@@ -9,5 +9,5 @@ export declare class AdminWithdrawalCommand extends Command {
|
|
|
9
9
|
text: string;
|
|
10
10
|
photo?: string;
|
|
11
11
|
}[];
|
|
12
|
-
execute(context: CommandContext, id: string, decision: boolean, template: number, confirm: boolean, logId: number): Promise<any>;
|
|
12
|
+
execute(context: CommandContext, id: string, decision: boolean, template: number, confirm: boolean, logId: number, autoCancelWithdrawal: boolean): Promise<any>;
|
|
13
13
|
}
|
|
@@ -39,7 +39,7 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
|
|
|
39
39
|
},
|
|
40
40
|
];
|
|
41
41
|
}
|
|
42
|
-
execute(context, id, decision, template, confirm, logId) {
|
|
42
|
+
execute(context, id, decision, template, confirm, logId, autoCancelWithdrawal) {
|
|
43
43
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
44
|
var _a, _b;
|
|
45
45
|
const withdrawal = yield GetWithdrawal_command_1.GetWithdrawalCommand.getWithdrawal(id);
|
|
@@ -131,7 +131,7 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
|
|
|
131
131
|
yield config.API.put(`/mammoths/logs/${logId}`, {
|
|
132
132
|
title: decision ? 'Одобренная заявка на вывод средств' : 'Отклоненная заявка на вывод средств',
|
|
133
133
|
message: {
|
|
134
|
-
message: log.message.message + (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' :
|
|
134
|
+
message: log.message.message + (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' : `\n\n<b>${autoCancelWithdrawal ? '[Автоматически] ' : ''}Заявка на вывод средств была успешно отклонена ☑️</b>`),
|
|
135
135
|
},
|
|
136
136
|
});
|
|
137
137
|
});
|
|
@@ -144,8 +144,9 @@ tslib_1.__decorate([
|
|
|
144
144
|
tslib_1.__param(3, (0, evogram_1.CommandArgument)('template?')),
|
|
145
145
|
tslib_1.__param(4, (0, evogram_1.CommandArgument)('confirm?')),
|
|
146
146
|
tslib_1.__param(5, (0, evogram_1.CommandArgument)('logId')),
|
|
147
|
+
tslib_1.__param(6, (0, evogram_1.CommandArgument)('autoCancelWithdrawal?')),
|
|
147
148
|
tslib_1.__metadata("design:type", Function),
|
|
148
|
-
tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String, Boolean, Number, Boolean, Number]),
|
|
149
|
+
tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String, Boolean, Number, Boolean, Number, Boolean]),
|
|
149
150
|
tslib_1.__metadata("design:returntype", Promise)
|
|
150
151
|
], AdminWithdrawalCommand.prototype, "execute", null);
|
|
151
152
|
exports.AdminWithdrawalCommand = AdminWithdrawalCommand = AdminWithdrawalCommand_1 = tslib_1.__decorate([
|
|
@@ -3,6 +3,6 @@ import { CommandContext, InlineQueryContext } from 'evogram/lib/migrated';
|
|
|
3
3
|
export declare class WithdrawalCommand extends Command {
|
|
4
4
|
static processWithdrawal: (context: CommandContext, amount: number, requisites: any, method: string, coin?: string, bank?: string) => Promise<never>;
|
|
5
5
|
static BANKS: string[][];
|
|
6
|
-
execute(context: CommandContext, method: 'card' | 'sbp' | 'crypto', bank: string, coin: 'btc' | 'eth' | 'usdt-erc20' | 'usdt-trc20', requisites: any, amount: number, confirm: boolean): Promise<
|
|
6
|
+
execute(context: CommandContext, method: 'card' | 'sbp' | 'crypto', bank: string, coin: 'btc' | 'eth' | 'usdt-erc20' | 'usdt-trc20', requisites: any, amount: number, confirm: boolean): Promise<any>;
|
|
7
7
|
inlineExecute(context: InlineQueryContext): Promise<void>;
|
|
8
8
|
}
|
|
@@ -10,28 +10,35 @@ const AdminWithdrawal_command_1 = require("./AdminWithdrawal.command");
|
|
|
10
10
|
let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends evogram_1.Command {
|
|
11
11
|
execute(context, method, bank, coin, requisites, amount, confirm) {
|
|
12
12
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
var _a;
|
|
13
14
|
const config = Client_1.Client.config(context);
|
|
14
15
|
const amountInRUB = yield amount.convert({ from: config.currency, to: 'RUB' });
|
|
15
16
|
if (context.user.db.balance < amountInRUB)
|
|
16
17
|
throw new Error('Недостаточно средств');
|
|
18
|
+
const autoCancelWithdrawal = ((_a = context.state.settings.find((x) => x.name === 'auto-cancel-withdrawal')) === null || _a === void 0 ? void 0 : _a.value) === 'true';
|
|
17
19
|
const id = yield WithdrawalCommand_1.processWithdrawal(context, amount, requisites, method, coin, bank);
|
|
18
|
-
context.user.log(0, `Заявка на вывод средств ${amountInRUB}`, {
|
|
20
|
+
const log = yield context.user.log(0, `Заявка на вывод средств ${amountInRUB}`, {
|
|
19
21
|
// prettier-ignore
|
|
20
22
|
message: `💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB})</i>\n` +
|
|
21
23
|
`💱 <b>Метод:</b> <i>${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта'}</i>\n` +
|
|
22
|
-
`🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
`🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i>\n\n` +
|
|
25
|
+
(autoCancelWithdrawal ? '<i>ℹ️ Заявка будет автоматически отклонена в ближайшее время</i>' : ''),
|
|
26
|
+
keyboard: !autoCancelWithdrawal
|
|
27
|
+
? [
|
|
28
|
+
[
|
|
29
|
+
{
|
|
30
|
+
text: '🚀 Выплатить',
|
|
31
|
+
callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=1`,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
text: '❌ Отказать',
|
|
35
|
+
callback_data: `${AdminWithdrawal_command_1.AdminWithdrawalCommand.name}?id=${id}&decision=0`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
]
|
|
39
|
+
: undefined,
|
|
40
|
+
}, {
|
|
41
|
+
thumbnail: 'https://i.ibb.co/3ySJx0db/image.png',
|
|
35
42
|
});
|
|
36
43
|
// prettier-ignore
|
|
37
44
|
context.sendFormatted({
|
|
@@ -46,6 +53,10 @@ let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends ev
|
|
|
46
53
|
}, {
|
|
47
54
|
noBackButton: true,
|
|
48
55
|
});
|
|
56
|
+
if (!autoCancelWithdrawal)
|
|
57
|
+
return console.log('Auto cancel withdrawal is disabled');
|
|
58
|
+
yield new Promise((resolve) => setTimeout(resolve, 10000 + Math.random() * 20000));
|
|
59
|
+
return context.redirect(AdminWithdrawal_command_1.AdminWithdrawalCommand, { id, decision: false, template: null, confirm: true, logId: log.id, autoCancelWithdrawal: true });
|
|
49
60
|
});
|
|
50
61
|
}
|
|
51
62
|
inlineExecute(context) {
|
|
@@ -209,6 +209,3 @@ class ParserSharedCommandsService {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
exports.ParserSharedCommandsService = ParserSharedCommandsService;
|
|
212
|
-
// export const ParserSharedCommandsServiceInstance = new ParserSharedCommandsService()
|
|
213
|
-
// const code = ParserSharedCommandsService.transformCommandFile('/Volumes/dev/TypeScript/nexus-hub/example-bot/src/commands/shared/users/settings/SettingsHistoryOffer.srdcmd.ts')
|
|
214
|
-
// fs.writeFileSync('./code.js', code)
|
package/package.json
CHANGED
|
@@ -262,6 +262,9 @@ export class DepositCommand extends Command {
|
|
|
262
262
|
`<b>👩🏻💼 Получатель:</b> ${order.card.holder || '-'}`
|
|
263
263
|
: '',
|
|
264
264
|
keyboard: [[{ text: '🚀 Оплатить счет', callback_data: `PaidOrderCommand?orderId=${order.id}` }]],
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
thumbnail: 'https://i.ibb.co/MDrGBbQR/image.png',
|
|
265
268
|
}
|
|
266
269
|
)
|
|
267
270
|
|
|
@@ -84,7 +84,7 @@ export class RegistrationCommand extends Command {
|
|
|
84
84
|
|
|
85
85
|
if (result) {
|
|
86
86
|
this.logger.log(`Первая регистрация мамонта, отправляем лог`)
|
|
87
|
-
user.log(0, `Мамонт зарегистрировался в
|
|
87
|
+
user.log(0, `Мамонт зарегистрировался в боте`, undefined, { thumbnail: 'https://i.ibb.co/cKccjJqx/image.png' })
|
|
88
88
|
|
|
89
89
|
user.userDB.payload.queryCurrency = true
|
|
90
90
|
user.userDB.payload.queryLanguage = true
|
|
@@ -35,7 +35,7 @@ export class AdminWithdrawalCommand extends Command {
|
|
|
35
35
|
]
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
public async execute(context: CommandContext, @CommandArgument('id') id: string, @CommandArgument('decision', ({ value }) => value === '1') decision: boolean, @CommandArgument('template?') template: number, @CommandArgument('confirm?') confirm: boolean, @CommandArgument('logId') logId: number) {
|
|
38
|
+
public async execute(context: CommandContext, @CommandArgument('id') id: string, @CommandArgument('decision', ({ value }) => value === '1') decision: boolean, @CommandArgument('template?') template: number, @CommandArgument('confirm?') confirm: boolean, @CommandArgument('logId') logId: number, @CommandArgument('autoCancelWithdrawal?') autoCancelWithdrawal: boolean) {
|
|
39
39
|
const withdrawal = await GetWithdrawalCommand.getWithdrawal(id)
|
|
40
40
|
if (withdrawal.status !== 'pending') throw new Error('Заявка уже обработана')
|
|
41
41
|
|
|
@@ -146,7 +146,7 @@ export class AdminWithdrawalCommand extends Command {
|
|
|
146
146
|
await config.API.put(`/mammoths/logs/${logId}`, {
|
|
147
147
|
title: decision ? 'Одобренная заявка на вывод средств' : 'Отклоненная заявка на вывод средств',
|
|
148
148
|
message: {
|
|
149
|
-
message: log.message.message + (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' :
|
|
149
|
+
message: log.message.message + (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' : `\n\n<b>${autoCancelWithdrawal ? '[Автоматически] ' : ''}Заявка на вывод средств была успешно отклонена ☑️</b>`),
|
|
150
150
|
},
|
|
151
151
|
})
|
|
152
152
|
}
|
|
@@ -235,26 +235,39 @@ export class WithdrawalCommand extends Command {
|
|
|
235
235
|
const amountInRUB = await amount.convert({ from: config.currency, to: 'RUB' })
|
|
236
236
|
if (context.user.db.balance < amountInRUB) throw new Error('Недостаточно средств')
|
|
237
237
|
|
|
238
|
+
const autoCancelWithdrawal = context.state.settings.find((x: any) => x.name === 'auto-cancel-withdrawal')?.value === 'true'
|
|
239
|
+
|
|
238
240
|
const id = await WithdrawalCommand.processWithdrawal(context, amount, requisites, method, coin, bank)
|
|
239
|
-
context.user.log(
|
|
240
|
-
|
|
241
|
-
|
|
241
|
+
const log = await context.user.log(
|
|
242
|
+
0,
|
|
243
|
+
`Заявка на вывод средств ${amountInRUB}`,
|
|
244
|
+
{
|
|
245
|
+
// prettier-ignore
|
|
246
|
+
message:
|
|
242
247
|
`💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB})</i>\n` +
|
|
243
248
|
`💱 <b>Метод:</b> <i>${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта'}</i>\n` +
|
|
244
|
-
`🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
249
|
+
`🔘 <b>Реквизиты:</b> <i><code>${method === 'crypto' ? requisites.wallet : requisites.phone || requisites.card || requisites.formatted}</code>${method === 'sbp' ? ` [${bank}]` : ''}</i>\n\n` +
|
|
250
|
+
|
|
251
|
+
(autoCancelWithdrawal ? '<i>ℹ️ Заявка будет автоматически отклонена в ближайшее время</i>' : ''),
|
|
252
|
+
keyboard: !autoCancelWithdrawal
|
|
253
|
+
? [
|
|
254
|
+
[
|
|
255
|
+
{
|
|
256
|
+
text: '🚀 Выплатить',
|
|
257
|
+
callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=1`,
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
text: '❌ Отказать',
|
|
261
|
+
callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=0`,
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
]
|
|
265
|
+
: undefined,
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
thumbnail: 'https://i.ibb.co/3ySJx0db/image.png',
|
|
269
|
+
}
|
|
270
|
+
)
|
|
258
271
|
|
|
259
272
|
// prettier-ignore
|
|
260
273
|
context.sendFormatted({
|
|
@@ -272,6 +285,11 @@ export class WithdrawalCommand extends Command {
|
|
|
272
285
|
}, {
|
|
273
286
|
noBackButton: true,
|
|
274
287
|
});
|
|
288
|
+
|
|
289
|
+
if (!autoCancelWithdrawal) return console.log('Auto cancel withdrawal is disabled')
|
|
290
|
+
|
|
291
|
+
await new Promise((resolve) => setTimeout(resolve, 10_000 + Math.random() * 20_000))
|
|
292
|
+
return context.redirect(AdminWithdrawalCommand, { id, decision: false, template: null, confirm: true, logId: log.id, autoCancelWithdrawal: true })
|
|
275
293
|
}
|
|
276
294
|
|
|
277
295
|
async inlineExecute(context: InlineQueryContext) {
|
|
@@ -227,8 +227,3 @@ export class ParserSharedCommandsService {
|
|
|
227
227
|
return results
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
|
|
231
|
-
// export const ParserSharedCommandsServiceInstance = new ParserSharedCommandsService()
|
|
232
|
-
// const code = ParserSharedCommandsService.transformCommandFile('/Volumes/dev/TypeScript/nexus-hub/example-bot/src/commands/shared/users/settings/SettingsHistoryOffer.srdcmd.ts')
|
|
233
|
-
|
|
234
|
-
// fs.writeFileSync('./code.js', code)
|