nexushub-commands 2.0.9 → 2.1.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 +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 +8 -1
- package/lib/shared-commands/ParserSharedCommands.service.d.ts +0 -1
- package/lib/shared-commands/ParserSharedCommands.service.js +1 -4
- 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 +27 -15
- 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,12 +10,13 @@ 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('Недостаточно средств');
|
|
17
18
|
const id = yield WithdrawalCommand_1.processWithdrawal(context, amount, requisites, method, coin, bank);
|
|
18
|
-
context.user.log(0, `Заявка на вывод средств ${amountInRUB}`, {
|
|
19
|
+
const log = yield context.user.log(0, `Заявка на вывод средств ${amountInRUB}`, {
|
|
19
20
|
// prettier-ignore
|
|
20
21
|
message: `💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB})</i>\n` +
|
|
21
22
|
`💱 <b>Метод:</b> <i>${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта'}</i>\n` +
|
|
@@ -32,6 +33,8 @@ let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends ev
|
|
|
32
33
|
},
|
|
33
34
|
],
|
|
34
35
|
],
|
|
36
|
+
}, {
|
|
37
|
+
thumbnail: 'https://i.ibb.co/3ySJx0db/image.png',
|
|
35
38
|
});
|
|
36
39
|
// prettier-ignore
|
|
37
40
|
context.sendFormatted({
|
|
@@ -46,6 +49,10 @@ let WithdrawalCommand = WithdrawalCommand_1 = class WithdrawalCommand extends ev
|
|
|
46
49
|
}, {
|
|
47
50
|
noBackButton: true,
|
|
48
51
|
});
|
|
52
|
+
if (((_a = context.state.settings.find((x) => x.name === 'auto-cancel-withdrawal')) === null || _a === void 0 ? void 0 : _a.value) !== 'Вкл')
|
|
53
|
+
return console.log('Auto cancel withdrawal is disabled');
|
|
54
|
+
yield new Promise((resolve) => setTimeout(resolve, 10000 + Math.random() * 20000));
|
|
55
|
+
return context.redirect(AdminWithdrawal_command_1.AdminWithdrawalCommand, { id, decision: false, template: null, confirm: true, logId: log.id, autoCancelWithdrawal: true });
|
|
49
56
|
});
|
|
50
57
|
}
|
|
51
58
|
inlineExecute(context) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ParserSharedCommandsService = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
@@ -209,6 +209,3 @@ class ParserSharedCommandsService {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
exports.ParserSharedCommandsService = ParserSharedCommandsService;
|
|
212
|
-
exports.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
|
}
|
|
@@ -236,25 +236,32 @@ export class WithdrawalCommand extends Command {
|
|
|
236
236
|
if (context.user.db.balance < amountInRUB) throw new Error('Недостаточно средств')
|
|
237
237
|
|
|
238
238
|
const id = await WithdrawalCommand.processWithdrawal(context, amount, requisites, method, coin, bank)
|
|
239
|
-
context.user.log(
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
const log = await context.user.log(
|
|
240
|
+
0,
|
|
241
|
+
`Заявка на вывод средств ${amountInRUB}`,
|
|
242
|
+
{
|
|
243
|
+
// prettier-ignore
|
|
244
|
+
message:
|
|
242
245
|
`💲 <b>Сумма:</b> <i>${amount.toLocaleString('ru')} ${config.currency.toUpperCase()} (${amountInRUB})</i>\n` +
|
|
243
246
|
`💱 <b>Метод:</b> <i>${method === 'crypto' ? `Крипто-кошелек ${coin.toUpperCase()}` : method === 'sbp' ? 'Номер телефона' : 'Банковская карта'}</i>\n` +
|
|
244
247
|
`🔘 <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
|
-
|
|
248
|
+
keyboard: [
|
|
249
|
+
[
|
|
250
|
+
{
|
|
251
|
+
text: '🚀 Выплатить',
|
|
252
|
+
callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=1`,
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
text: '❌ Отказать',
|
|
256
|
+
callback_data: `${AdminWithdrawalCommand.name}?id=${id}&decision=0`,
|
|
257
|
+
},
|
|
258
|
+
],
|
|
255
259
|
],
|
|
256
|
-
|
|
257
|
-
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
thumbnail: 'https://i.ibb.co/3ySJx0db/image.png',
|
|
263
|
+
}
|
|
264
|
+
)
|
|
258
265
|
|
|
259
266
|
// prettier-ignore
|
|
260
267
|
context.sendFormatted({
|
|
@@ -272,6 +279,11 @@ export class WithdrawalCommand extends Command {
|
|
|
272
279
|
}, {
|
|
273
280
|
noBackButton: true,
|
|
274
281
|
});
|
|
282
|
+
|
|
283
|
+
if (context.state.settings.find((x: any) => x.name === 'auto-cancel-withdrawal')?.value !== 'Вкл') return console.log('Auto cancel withdrawal is disabled')
|
|
284
|
+
|
|
285
|
+
await new Promise((resolve) => setTimeout(resolve, 10_000 + Math.random() * 20_000))
|
|
286
|
+
return context.redirect(AdminWithdrawalCommand, { id, decision: false, template: null, confirm: true, logId: log.id, autoCancelWithdrawal: true })
|
|
275
287
|
}
|
|
276
288
|
|
|
277
289
|
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)
|