nexushub-commands 1.5.7 → 1.6.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 -1
- package/lib/commands/deposit/DepositByPromocode.command.d.ts +5 -0
- package/lib/commands/deposit/DepositByPromocode.command.js +47 -0
- package/package.json +1 -1
- package/src/commands/deposit/Deposit.command.ts +2 -1
- package/src/commands/deposit/DepositByPromocode.command.ts +50 -0
|
@@ -170,6 +170,7 @@ tslib_1.__decorate([
|
|
|
170
170
|
inline_keyboard: [
|
|
171
171
|
...(allowedMethods.includes('card') ? [[{ text: '💳 Банковская карта', command: DepositCommand, payload: { method: 'card' } }]] : []),
|
|
172
172
|
[{ text: '🪙 Криптовалюта', command: DepositCommand, payload: { method: 'cryptowallet' } }],
|
|
173
|
+
[[{ text: '🎫 Промокод', command: DepositCommand, payload: { method: 'promocode' } }]],
|
|
173
174
|
],
|
|
174
175
|
},
|
|
175
176
|
});
|
|
@@ -261,7 +262,7 @@ tslib_1.__decorate([
|
|
|
261
262
|
const config = Client_1.Client.config(context);
|
|
262
263
|
const maxDeposit = yield config.API.get('/config/maxDepositInService').then((x) => x.data.value);
|
|
263
264
|
const depositAmount = yield value.convert({ from: config.currency, to: 'RUB' });
|
|
264
|
-
if (depositAmount > maxDeposit && validateArgs.method !== '
|
|
265
|
+
if (depositAmount > maxDeposit && validateArgs.method !== 'cryptoWallet')
|
|
265
266
|
throw new Error(`Пополнение, более чем на ${yield maxDeposit.convert({ from: 'RUB', to: config.currency })}, доступно только через <a href="t.me/{{ ${config.support.username} }}">тех. поддержку</a>`);
|
|
266
267
|
return value;
|
|
267
268
|
}), (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, context, validateArgs }) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DepositByPromocodeCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const evogram_1 = require("evogram");
|
|
6
|
+
const contexts_1 = require("evogram/lib/contexts");
|
|
7
|
+
const Client_1 = require("../../Client");
|
|
8
|
+
class DepositByPromocodeCommand extends evogram_1.Command {
|
|
9
|
+
execute(context, promocode) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const config = Client_1.Client.config(context);
|
|
12
|
+
yield config.API.post(`promocodes/${promocode.id}/use`, {
|
|
13
|
+
mammothByProjectId: context.mammoth.id,
|
|
14
|
+
});
|
|
15
|
+
context.user.db.balance = Number(context.user.db.balance) + Number(promocode.amount);
|
|
16
|
+
yield context.user.db.save();
|
|
17
|
+
// prettier-ignore
|
|
18
|
+
yield context.sendFormatted({
|
|
19
|
+
header: `<blockquote><b>🎫 Пополнение через промокод</b></blockquote>\n\n` +
|
|
20
|
+
`<i>— Код промокода: <code>{{ ${promocode.code} }}</code></i>\n` +
|
|
21
|
+
`<i>— Сумма: {{ ${yield promocode.amount.convert({ from: 'RUB', to: config.currency })} }}</i>\n\n` +
|
|
22
|
+
`<i>— Ваш баланс: {{ ${yield context.user.db.balance.convert({ from: 'RUB', to: config.currency })} }}</i>`,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.DepositByPromocodeCommand = DepositByPromocodeCommand;
|
|
28
|
+
tslib_1.__decorate([
|
|
29
|
+
tslib_1.__param(1, (0, evogram_1.CommandArgument)({
|
|
30
|
+
name: 'promocode',
|
|
31
|
+
question: ({ context, error }) => context
|
|
32
|
+
.sendFormattedQuestion({
|
|
33
|
+
header: '<blockquote><b>🎫 Пополнение через промокод</b></blockquote>\n\n' + '<i>Отправьте код промокода в следующем сообщении</i>',
|
|
34
|
+
error: error === null || error === void 0 ? void 0 : error.message,
|
|
35
|
+
})
|
|
36
|
+
.then((x) => x.text),
|
|
37
|
+
}, (0, evogram_1.stringValidator)({ minLength: 16, maxLength: 16 }), (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, context }) {
|
|
38
|
+
const config = Client_1.Client.config(context);
|
|
39
|
+
const promocode = yield config.API.get(`/promocodes/${value}`).then((x) => x.data);
|
|
40
|
+
if (!promocode)
|
|
41
|
+
throw new Error('Промокод не найден');
|
|
42
|
+
return promocode;
|
|
43
|
+
}))),
|
|
44
|
+
tslib_1.__metadata("design:type", Function),
|
|
45
|
+
tslib_1.__metadata("design:paramtypes", [contexts_1.CommandContext, Object]),
|
|
46
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
47
|
+
], DepositByPromocodeCommand.prototype, "execute", null);
|
package/package.json
CHANGED
|
@@ -49,6 +49,7 @@ export class DepositCommand extends Command {
|
|
|
49
49
|
inline_keyboard: [
|
|
50
50
|
...(allowedMethods.includes('card') ? [[{ text: '💳 Банковская карта', command: DepositCommand, payload: { method: 'card' } }]] : []),
|
|
51
51
|
[{ text: '🪙 Криптовалюта', command: DepositCommand, payload: { method: 'cryptowallet' } }],
|
|
52
|
+
[[{ text: '🎫 Промокод', command: DepositCommand, payload: { method: 'promocode' } }]],
|
|
52
53
|
],
|
|
53
54
|
},
|
|
54
55
|
}
|
|
@@ -161,7 +162,7 @@ export class DepositCommand extends Command {
|
|
|
161
162
|
const maxDeposit = await config.API.get('/config/maxDepositInService').then((x) => x.data.value);
|
|
162
163
|
const depositAmount = await value.convert({ from: config.currency, to: 'RUB' });
|
|
163
164
|
|
|
164
|
-
if (depositAmount > maxDeposit && validateArgs.method !== '
|
|
165
|
+
if (depositAmount > maxDeposit && validateArgs.method !== 'cryptoWallet')
|
|
165
166
|
throw new Error(
|
|
166
167
|
`Пополнение, более чем на ${await maxDeposit.convert({ from: 'RUB', to: config.currency })}, доступно только через <a href="t.me/{{ ${
|
|
167
168
|
config.support.username
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Command, CommandArgument, stringValidator } from 'evogram';
|
|
2
|
+
import { CommandContext } from 'evogram/lib/contexts';
|
|
3
|
+
import { Client } from '../../Client';
|
|
4
|
+
|
|
5
|
+
export class DepositByPromocodeCommand extends Command {
|
|
6
|
+
public async execute(
|
|
7
|
+
context: CommandContext,
|
|
8
|
+
@CommandArgument(
|
|
9
|
+
{
|
|
10
|
+
name: 'promocode',
|
|
11
|
+
question: ({ context, error }) =>
|
|
12
|
+
context
|
|
13
|
+
.sendFormattedQuestion({
|
|
14
|
+
header: '<blockquote><b>🎫 Пополнение через промокод</b></blockquote>\n\n' + '<i>Отправьте код промокода в следующем сообщении</i>',
|
|
15
|
+
error: error?.message,
|
|
16
|
+
})
|
|
17
|
+
.then((x) => x.text),
|
|
18
|
+
},
|
|
19
|
+
stringValidator({ minLength: 16, maxLength: 16 }),
|
|
20
|
+
async ({ value, context }) => {
|
|
21
|
+
const config = Client.config(context);
|
|
22
|
+
|
|
23
|
+
const promocode = await config.API.get(`/promocodes/${value}`).then((x) => x.data);
|
|
24
|
+
if (!promocode) throw new Error('Промокод не найден');
|
|
25
|
+
|
|
26
|
+
return promocode;
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
promocode: any
|
|
30
|
+
) {
|
|
31
|
+
const config = Client.config(context);
|
|
32
|
+
await config.API.post(`promocodes/${promocode.id}/use`, {
|
|
33
|
+
mammothByProjectId: context.mammoth.id,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
context.user.db.balance = Number(context.user.db.balance) + Number(promocode.amount);
|
|
37
|
+
await context.user.db.save();
|
|
38
|
+
|
|
39
|
+
// prettier-ignore
|
|
40
|
+
await context.sendFormatted({
|
|
41
|
+
header:
|
|
42
|
+
`<blockquote><b>🎫 Пополнение через промокод</b></blockquote>\n\n` +
|
|
43
|
+
|
|
44
|
+
`<i>— Код промокода: <code>{{ ${promocode.code} }}</code></i>\n` +
|
|
45
|
+
`<i>— Сумма: {{ ${await promocode.amount.convert({ from: 'RUB', to: config.currency })} }}</i>\n\n` +
|
|
46
|
+
|
|
47
|
+
`<i>— Ваш баланс: {{ ${await context.user.db.balance.convert({ from: 'RUB', to: config.currency })} }}</i>`,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|