nexushub-commands 2.1.2 → 2.2.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.
|
@@ -8,12 +8,13 @@ const migrated_1 = require("evogram/lib/migrated");
|
|
|
8
8
|
const Client_1 = require("../../Client");
|
|
9
9
|
let RegistrationCommand = RegistrationCommand_1 = class RegistrationCommand extends migrated_1.Command {
|
|
10
10
|
isExecutable(context) {
|
|
11
|
-
var _a;
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
12
|
if (context.state.fromMirror)
|
|
13
13
|
return false;
|
|
14
14
|
if (!((_a = context.state.mammoth) === null || _a === void 0 ? void 0 : _a.mirror))
|
|
15
15
|
return true;
|
|
16
|
-
|
|
16
|
+
const [, , refCode] = /(\/(start|registration)(\s)?(\d+))?/.exec(context.text) || [];
|
|
17
|
+
if (((_b = context.state.mirror) === null || _b === void 0 ? void 0 : _b.isMain) && refCode && Number((_d = (_c = context.user.userDB) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.refCode) !== Number(refCode))
|
|
17
18
|
return true;
|
|
18
19
|
return false;
|
|
19
20
|
}
|
|
@@ -21,8 +22,8 @@ let RegistrationCommand = RegistrationCommand_1 = class RegistrationCommand exte
|
|
|
21
22
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
var _a;
|
|
23
24
|
const config = Client_1.Client.config(context);
|
|
24
|
-
if (/\/start \d+/.test(context.text) || Number(context.text))
|
|
25
|
-
context.user.userDB.payload.refCode = Number((_a = /(\/start )?(\d+)/.exec(context.text)) === null || _a === void 0 ? void 0 : _a[2]);
|
|
25
|
+
if (/\/(start|registration) \d+/.test(context.text) || Number(context.text))
|
|
26
|
+
context.user.userDB.payload.refCode = Number((_a = /(\/(start|registration) )?(\d+)/.exec(context.text)) === null || _a === void 0 ? void 0 : _a[2]);
|
|
26
27
|
if (!context.user.userDB.payload.agreement)
|
|
27
28
|
return context.sendFormatted({
|
|
28
29
|
body: [
|
|
@@ -87,7 +87,10 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
|
|
|
87
87
|
},
|
|
88
88
|
},
|
|
89
89
|
]),
|
|
90
|
-
[
|
|
90
|
+
[
|
|
91
|
+
{ text: 'Своя причина', command: AdminWithdrawalCommand_1, payload: { id, decision: false, template: 'custom', logId } },
|
|
92
|
+
{ text: 'Пропустить этап', command: AdminWithdrawalCommand_1, payload: { id, decision: false, template: null, confirm: true, logId } },
|
|
93
|
+
],
|
|
91
94
|
],
|
|
92
95
|
},
|
|
93
96
|
});
|
|
@@ -95,7 +98,7 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
|
|
|
95
98
|
if (!confirm) {
|
|
96
99
|
return context.sendFormatted({
|
|
97
100
|
noPhoto: true,
|
|
98
|
-
header: `<blockquote><b>${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].text}
|
|
101
|
+
header: AdminWithdrawalCommand_1.getRejectedMessages(config)[template] ? `<blockquote><b>${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].text}` : '<blockquote><b>❌ Причина отклонения</b></blockquote>\n\n' + template,
|
|
99
102
|
}, {
|
|
100
103
|
reply_markup: {
|
|
101
104
|
inline_keyboard: [
|
|
@@ -121,11 +124,13 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
|
|
|
121
124
|
parse_mode: 'HTML',
|
|
122
125
|
});
|
|
123
126
|
if (template !== null) {
|
|
124
|
-
|
|
127
|
+
//@ts-ignore
|
|
128
|
+
msg.reply(AdminWithdrawalCommand_1.getRejectedMessages(config)[template] ? `<blockquote>${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].title}</blockquote>\n\n${AdminWithdrawalCommand_1.getRejectedMessages(config)[template].text}` : '<blockquote><b>❌ Причина отклонения</b></blockquote>\n\n' + template, {
|
|
125
129
|
parse_mode: 'HTML',
|
|
126
130
|
reply_markup: { inline_keyboard: [[{ text: '👨💻 Тех. поддержка', url: `https://t.me/${config.support.username}` }]] },
|
|
127
131
|
});
|
|
128
132
|
}
|
|
133
|
+
console.log({ logId });
|
|
129
134
|
}
|
|
130
135
|
const log = yield config.API.get(`/mammoths/logs/${logId}`).then((x) => x.data);
|
|
131
136
|
yield config.API.put(`/mammoths/logs/${logId}`, {
|
|
@@ -141,7 +146,7 @@ exports.AdminWithdrawalCommand = AdminWithdrawalCommand;
|
|
|
141
146
|
tslib_1.__decorate([
|
|
142
147
|
tslib_1.__param(1, (0, evogram_1.CommandArgument)('id')),
|
|
143
148
|
tslib_1.__param(2, (0, evogram_1.CommandArgument)('decision', ({ value }) => value === '1')),
|
|
144
|
-
tslib_1.__param(3, (0, evogram_1.CommandArgument)('template?')),
|
|
149
|
+
tslib_1.__param(3, (0, evogram_1.CommandArgument)({ name: 'template?' }, (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ context, value }) { return (value === 'custom' ? context.sendFormattedQuestion({ noPhoto: true, header: '<blockquote><b>✍️ Причина отклонения</b></blockquote>', footer: '<i>Отправьте текст сообщения, который будет отображен пользователю при отмене вывода</i>' }).then((x) => (0, evogram_1.entitiesToString)(x.text, x.entities || [], 'HTML')) : value); }))),
|
|
145
150
|
tslib_1.__param(4, (0, evogram_1.CommandArgument)('confirm?')),
|
|
146
151
|
tslib_1.__param(5, (0, evogram_1.CommandArgument)('logId')),
|
|
147
152
|
tslib_1.__param(6, (0, evogram_1.CommandArgument)('autoCancelWithdrawal?')),
|
package/package.json
CHANGED
|
@@ -6,9 +6,10 @@ import { Client, DepositConfig } from '../../Client'
|
|
|
6
6
|
export class RegistrationCommand extends Command {
|
|
7
7
|
public isExecutable(context: CommandContext): boolean {
|
|
8
8
|
if (context.state.fromMirror) return false
|
|
9
|
-
|
|
10
9
|
if (!context.state.mammoth?.mirror) return true
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
const [, , refCode] = /(\/(start|registration)(\s)?(\d+))?/.exec(context.text!) || []
|
|
12
|
+
if (context.state.mirror?.isMain && refCode && Number(context.user.userDB?.payload?.refCode) !== Number(refCode)) return true
|
|
12
13
|
|
|
13
14
|
return false
|
|
14
15
|
}
|
|
@@ -16,7 +17,7 @@ export class RegistrationCommand extends Command {
|
|
|
16
17
|
public async execute(context: CommandContext) {
|
|
17
18
|
const config = Client.config(context)
|
|
18
19
|
|
|
19
|
-
if (/\/start \d+/.test(context.text!) || Number(context.text)) context.user.userDB.payload.refCode = Number(/(\/start )?(\d+)/.exec(context.text!)?.[2])
|
|
20
|
+
if (/\/(start|registration) \d+/.test(context.text!) || Number(context.text)) context.user.userDB.payload.refCode = Number(/(\/(start|registration) )?(\d+)/.exec(context.text!)?.[2])
|
|
20
21
|
if (!context.user.userDB.payload.agreement)
|
|
21
22
|
return context.sendFormatted(
|
|
22
23
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command, CommandArgument, CommandD } from 'evogram'
|
|
1
|
+
import { Command, CommandArgument, CommandD, entitiesToString } from 'evogram'
|
|
2
2
|
import { CommandContext } from 'evogram/lib/migrated'
|
|
3
3
|
import { Client, DepositConfig } from '../../Client'
|
|
4
4
|
import { GetWithdrawalCommand } from './GetWithdrawal.command'
|
|
@@ -35,7 +35,18 @@ export class AdminWithdrawalCommand extends Command {
|
|
|
35
35
|
]
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
public async execute(
|
|
38
|
+
public async execute(
|
|
39
|
+
context: CommandContext,
|
|
40
|
+
|
|
41
|
+
@CommandArgument('id') id: string,
|
|
42
|
+
@CommandArgument('decision', ({ value }) => value === '1') decision: boolean,
|
|
43
|
+
@CommandArgument({ name: 'template?' }, async ({ context, value }) => (value === 'custom' ? context.sendFormattedQuestion({ noPhoto: true, header: '<blockquote><b>✍️ Причина отклонения</b></blockquote>', footer: '<i>Отправьте текст сообщения, который будет отображен пользователю при отмене вывода</i>' }).then((x) => entitiesToString(x.text, x.entities || [], 'HTML')) : value))
|
|
44
|
+
template: number,
|
|
45
|
+
|
|
46
|
+
@CommandArgument('confirm?') confirm: boolean,
|
|
47
|
+
@CommandArgument('logId') logId: number,
|
|
48
|
+
@CommandArgument('autoCancelWithdrawal?') autoCancelWithdrawal: boolean
|
|
49
|
+
) {
|
|
39
50
|
const withdrawal = await GetWithdrawalCommand.getWithdrawal(id)
|
|
40
51
|
if (withdrawal.status !== 'pending') throw new Error('Заявка уже обработана')
|
|
41
52
|
|
|
@@ -89,7 +100,10 @@ export class AdminWithdrawalCommand extends Command {
|
|
|
89
100
|
},
|
|
90
101
|
},
|
|
91
102
|
]),
|
|
92
|
-
[
|
|
103
|
+
[
|
|
104
|
+
{ text: 'Своя причина', command: AdminWithdrawalCommand, payload: { id, decision: false, template: 'custom', logId } },
|
|
105
|
+
{ text: 'Пропустить этап', command: AdminWithdrawalCommand, payload: { id, decision: false, template: null, confirm: true, logId } },
|
|
106
|
+
],
|
|
93
107
|
],
|
|
94
108
|
},
|
|
95
109
|
}
|
|
@@ -100,7 +114,7 @@ export class AdminWithdrawalCommand extends Command {
|
|
|
100
114
|
return context.sendFormatted(
|
|
101
115
|
{
|
|
102
116
|
noPhoto: true,
|
|
103
|
-
header: `<blockquote><b>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${AdminWithdrawalCommand.getRejectedMessages(config)[template].text}
|
|
117
|
+
header: AdminWithdrawalCommand.getRejectedMessages(config)[template] ? `<blockquote><b>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${AdminWithdrawalCommand.getRejectedMessages(config)[template].text}` : '<blockquote><b>❌ Причина отклонения</b></blockquote>\n\n' + template,
|
|
104
118
|
},
|
|
105
119
|
{
|
|
106
120
|
reply_markup: {
|
|
@@ -135,11 +149,14 @@ export class AdminWithdrawalCommand extends Command {
|
|
|
135
149
|
});
|
|
136
150
|
|
|
137
151
|
if (template !== null) {
|
|
138
|
-
|
|
152
|
+
//@ts-ignore
|
|
153
|
+
msg.reply(AdminWithdrawalCommand.getRejectedMessages(config)[template] ? `<blockquote>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</blockquote>\n\n${AdminWithdrawalCommand.getRejectedMessages(config)[template].text}` : '<blockquote><b>❌ Причина отклонения</b></blockquote>\n\n' + template, {
|
|
139
154
|
parse_mode: 'HTML',
|
|
140
155
|
reply_markup: { inline_keyboard: [[{ text: '👨💻 Тех. поддержка', url: `https://t.me/${config.support.username}` }]] },
|
|
141
156
|
})
|
|
142
157
|
}
|
|
158
|
+
|
|
159
|
+
console.log({ logId })
|
|
143
160
|
}
|
|
144
161
|
|
|
145
162
|
const log = await config.API.get(`/mammoths/logs/${logId}`).then((x) => x.data)
|