nexushub-commands 1.8.2 → 1.10.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/SendCheque.command.js +4 -6
- package/lib/commands/withdrawal/AdminWithdrawal.command.d.ts +1 -2
- package/lib/commands/withdrawal/AdminWithdrawal.command.js +16 -17
- package/package.json +1 -1
- package/src/commands/deposit/SendCheque.command.ts +24 -30
- package/src/commands/withdrawal/AdminWithdrawal.command.ts +32 -51
|
@@ -36,18 +36,16 @@ let SendChequeCommand = class SendChequeCommand extends migrated_1.Command {
|
|
|
36
36
|
const photoURL = yield axios_1.default
|
|
37
37
|
.request({
|
|
38
38
|
method: 'POST',
|
|
39
|
-
url: `
|
|
40
|
-
maxBodyLength: Infinity,
|
|
39
|
+
url: `http://localhost:6234/images/upload`,
|
|
41
40
|
headers: {
|
|
42
|
-
'Content-Type': '
|
|
41
|
+
'Content-Type': 'multipart/form-data',
|
|
43
42
|
},
|
|
44
43
|
data: qs.stringify({
|
|
45
|
-
url,
|
|
46
|
-
reqtype: 'urlupload',
|
|
44
|
+
imageUrl: url,
|
|
47
45
|
}),
|
|
48
46
|
timeout: 10000,
|
|
49
47
|
})
|
|
50
|
-
.then((x) => x.data)
|
|
48
|
+
.then((x) => x.data.url)
|
|
51
49
|
.catch(() => null);
|
|
52
50
|
if (!photoURL)
|
|
53
51
|
throw new Error('Не удалось загрузить фотографию, попробуйте позже');
|
|
@@ -9,6 +9,5 @@ export declare class AdminWithdrawalCommand extends Command {
|
|
|
9
9
|
text: string;
|
|
10
10
|
photo?: string;
|
|
11
11
|
}[];
|
|
12
|
-
|
|
13
|
-
execute(context: CommandContext, id: string, decision: boolean, template: number, confirm: boolean): Promise<any>;
|
|
12
|
+
execute(context: CommandContext, id: string, decision: boolean, template: number, confirm: boolean, logId: number): Promise<any>;
|
|
14
13
|
}
|
|
@@ -39,18 +39,18 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
|
|
|
39
39
|
},
|
|
40
40
|
];
|
|
41
41
|
}
|
|
42
|
-
execute(context, id, decision, template, confirm) {
|
|
42
|
+
execute(context, id, decision, template, confirm, logId) {
|
|
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);
|
|
46
|
-
if (
|
|
47
|
-
|
|
46
|
+
if (withdrawal.status !== 'pending')
|
|
47
|
+
throw new Error('Заявка уже обработана');
|
|
48
48
|
const withdrawalFormattedID = Math.floor(Math.random() * 500000000 + 500000000)
|
|
49
49
|
.toString(36)
|
|
50
50
|
.toUpperCase();
|
|
51
|
+
context.user.id = withdrawal.user;
|
|
51
52
|
const config = Client_1.Client.config(context);
|
|
52
53
|
const mammoth = yield config.API.get(`/projects/mammoths/${withdrawal.user}`).then((x) => x.data);
|
|
53
|
-
console.log(mammoth.mirror);
|
|
54
54
|
const client = yield config.getClient(mammoth.mirror.mirror.token);
|
|
55
55
|
if (decision) {
|
|
56
56
|
yield AdminWithdrawalCommand_1.approve(withdrawal.id);
|
|
@@ -83,10 +83,11 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
|
|
|
83
83
|
id,
|
|
84
84
|
decision: false,
|
|
85
85
|
template: i,
|
|
86
|
+
logId,
|
|
86
87
|
},
|
|
87
88
|
},
|
|
88
89
|
]),
|
|
89
|
-
[{ text: 'Пропустить этап', command: AdminWithdrawalCommand_1, payload: { id, decision: false, template: null, confirm: true } }],
|
|
90
|
+
[{ text: 'Пропустить этап', command: AdminWithdrawalCommand_1, payload: { id, decision: false, template: null, confirm: true, logId } }],
|
|
90
91
|
],
|
|
91
92
|
},
|
|
92
93
|
});
|
|
@@ -99,8 +100,8 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
|
|
|
99
100
|
reply_markup: {
|
|
100
101
|
inline_keyboard: [
|
|
101
102
|
[
|
|
102
|
-
{ text: '‹ Назад', command: AdminWithdrawalCommand_1, payload: { id, decision, template: undefined } },
|
|
103
|
-
{ text: 'Продолжить ›', command: AdminWithdrawalCommand_1, payload: { id, decision, template, confirm: true } },
|
|
103
|
+
{ text: '‹ Назад', command: AdminWithdrawalCommand_1, payload: { id, decision, template: undefined, logId } },
|
|
104
|
+
{ text: 'Продолжить ›', command: AdminWithdrawalCommand_1, payload: { id, decision, template, confirm: true, logId } },
|
|
104
105
|
],
|
|
105
106
|
],
|
|
106
107
|
},
|
|
@@ -126,27 +127,25 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
|
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
text: context.text + (decision ? '\n\nЗаявка на вывод средств была успешно обработана ☑️' : '\n\nЗаявка на вывод средств была успешно отклонена ☑️'),
|
|
136
|
-
entities: context.entities,
|
|
130
|
+
const log = yield config.API.get(`/mammoths/logs/${logId}`).then((x) => x.data);
|
|
131
|
+
yield config.API.put(`/mammoths/logs/${logId}`, {
|
|
132
|
+
title: decision ? 'Одобренная заявка на вывод средств' : 'Отклоненная заявка на вывод средств',
|
|
133
|
+
message: {
|
|
134
|
+
message: log.message.message + (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' : '\n\n<b>Заявка на вывод средств была успешно отклонена ☑️</b>'),
|
|
135
|
+
},
|
|
137
136
|
});
|
|
138
137
|
});
|
|
139
138
|
}
|
|
140
139
|
};
|
|
141
140
|
exports.AdminWithdrawalCommand = AdminWithdrawalCommand;
|
|
142
|
-
AdminWithdrawalCommand.logMessages = {};
|
|
143
141
|
tslib_1.__decorate([
|
|
144
142
|
tslib_1.__param(1, (0, evogram_1.CommandArgument)('id')),
|
|
145
143
|
tslib_1.__param(2, (0, evogram_1.CommandArgument)('decision', ({ value }) => value === '1')),
|
|
146
144
|
tslib_1.__param(3, (0, evogram_1.CommandArgument)('template?')),
|
|
147
145
|
tslib_1.__param(4, (0, evogram_1.CommandArgument)('confirm?')),
|
|
146
|
+
tslib_1.__param(5, (0, evogram_1.CommandArgument)('logId')),
|
|
148
147
|
tslib_1.__metadata("design:type", Function),
|
|
149
|
-
tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String, Boolean, Number, Boolean]),
|
|
148
|
+
tslib_1.__metadata("design:paramtypes", [migrated_1.CommandContext, String, Boolean, Number, Boolean, Number]),
|
|
150
149
|
tslib_1.__metadata("design:returntype", Promise)
|
|
151
150
|
], AdminWithdrawalCommand.prototype, "execute", null);
|
|
152
151
|
exports.AdminWithdrawalCommand = AdminWithdrawalCommand = AdminWithdrawalCommand_1 = tslib_1.__decorate([
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
import { CommandArgument, CommandD } from 'evogram'
|
|
3
|
-
import { Command, CommandContext } from 'evogram/lib/migrated'
|
|
4
|
-
import { Client } from '../../Client'
|
|
5
|
-
const qs = require('qs')
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import { CommandArgument, CommandD } from 'evogram'
|
|
3
|
+
import { Command, CommandContext } from 'evogram/lib/migrated'
|
|
4
|
+
import { Client } from '../../Client'
|
|
5
|
+
const qs = require('qs')
|
|
6
6
|
|
|
7
7
|
@CommandD({ name: 'sendCheque' })
|
|
8
8
|
export class SendChequeCommand extends Command {
|
|
9
9
|
public async execute(context: CommandContext, @CommandArgument('orderId') orderId: string) {
|
|
10
|
-
const config = Client.config(context)
|
|
10
|
+
const config = Client.config(context)
|
|
11
11
|
|
|
12
|
-
await config.API.get(`/orders/${orderId}/checkPaid`).catch(() => {})
|
|
13
|
-
const order = await config.API.get(`/orders/${orderId}`).then((x) => x.data)
|
|
12
|
+
await config.API.get(`/orders/${orderId}/checkPaid`).catch(() => {})
|
|
13
|
+
const order = await config.API.get(`/orders/${orderId}`).then((x) => x.data)
|
|
14
14
|
|
|
15
|
-
if (['paid', 'fakepaid'].includes(order.status)) throw new Error('Счет уже оплачен')
|
|
15
|
+
if (['paid', 'fakepaid'].includes(order.status)) throw new Error('Счет уже оплачен')
|
|
16
16
|
|
|
17
17
|
if (!order.cheque && ['card', 'qrcode'].includes(order.method))
|
|
18
18
|
return context.sendFormattedQuestion(
|
|
@@ -23,45 +23,39 @@ export class SendChequeCommand extends Command {
|
|
|
23
23
|
},
|
|
24
24
|
undefined,
|
|
25
25
|
async (msg) => {
|
|
26
|
-
let url: any = null
|
|
26
|
+
let url: any = null
|
|
27
27
|
if (msg.attachments.photo?.length) {
|
|
28
|
-
url = `https://api.telegram.org/file/bot${this.client.params.token}/${
|
|
29
|
-
(await this.client.api.getFile({ file_id: msg.attachments.photo.at(-1)!.file_id })).file_path
|
|
30
|
-
}`;
|
|
28
|
+
url = `https://api.telegram.org/file/bot${this.client.params.token}/${(await this.client.api.getFile({ file_id: msg.attachments.photo.at(-1)!.file_id })).file_path}`
|
|
31
29
|
} else if (msg.attachments.document) {
|
|
32
|
-
if (!msg.attachments.document.mime_type?.startsWith('image/')) throw new Error('Ваш файл не является изображением')
|
|
30
|
+
if (!msg.attachments.document.mime_type?.startsWith('image/')) throw new Error('Ваш файл не является изображением')
|
|
33
31
|
|
|
34
|
-
url = `https://api.telegram.org/file/bot${this.client.params.token}/${
|
|
35
|
-
(await this.client.api.getFile({ file_id: msg.attachments.document.file_id })).file_path
|
|
36
|
-
}`;
|
|
32
|
+
url = `https://api.telegram.org/file/bot${this.client.params.token}/${(await this.client.api.getFile({ file_id: msg.attachments.document.file_id })).file_path}`
|
|
37
33
|
}
|
|
38
34
|
|
|
39
|
-
if (!url) throw new Error('Пожалуйста, отправьте изображение с квитанцией в следующем сообщении')
|
|
35
|
+
if (!url) throw new Error('Пожалуйста, отправьте изображение с квитанцией в следующем сообщении')
|
|
40
36
|
const photoURL = await axios
|
|
41
37
|
.request({
|
|
42
38
|
method: 'POST',
|
|
43
|
-
url: `
|
|
44
|
-
maxBodyLength: Infinity,
|
|
39
|
+
url: `http://localhost:6234/images/upload`,
|
|
45
40
|
headers: {
|
|
46
|
-
'Content-Type': '
|
|
41
|
+
'Content-Type': 'multipart/form-data',
|
|
47
42
|
},
|
|
48
43
|
data: qs.stringify({
|
|
49
|
-
url,
|
|
50
|
-
reqtype: 'urlupload',
|
|
44
|
+
imageUrl: url,
|
|
51
45
|
}),
|
|
52
46
|
timeout: 10000,
|
|
53
47
|
})
|
|
54
|
-
.then((x) => x.data)
|
|
55
|
-
.catch(() => null)
|
|
48
|
+
.then((x) => x.data.url)
|
|
49
|
+
.catch(() => null)
|
|
56
50
|
|
|
57
|
-
if (!photoURL) throw new Error('Не удалось загрузить фотографию, попробуйте позже')
|
|
51
|
+
if (!photoURL) throw new Error('Не удалось загрузить фотографию, попробуйте позже')
|
|
58
52
|
await config.API.put(`/orders/${orderId}`, {
|
|
59
53
|
cheque: photoURL,
|
|
60
|
-
})
|
|
54
|
+
})
|
|
61
55
|
|
|
62
56
|
await context.user.log(0, `Отправлен чек на оплату счета`, {
|
|
63
57
|
photo: photoURL,
|
|
64
|
-
})
|
|
58
|
+
})
|
|
65
59
|
|
|
66
60
|
return context.sendFormatted(
|
|
67
61
|
{
|
|
@@ -72,8 +66,8 @@ export class SendChequeCommand extends Command {
|
|
|
72
66
|
{
|
|
73
67
|
noBackButton: true,
|
|
74
68
|
}
|
|
75
|
-
)
|
|
69
|
+
)
|
|
76
70
|
}
|
|
77
|
-
)
|
|
71
|
+
)
|
|
78
72
|
}
|
|
79
73
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Command, CommandArgument, CommandD } from 'evogram'
|
|
2
|
-
import { CommandContext } from 'evogram/lib/migrated'
|
|
3
|
-
import { Client, DepositConfig } from '../../Client'
|
|
4
|
-
import { GetWithdrawalCommand } from './GetWithdrawal.command'
|
|
1
|
+
import { Command, CommandArgument, CommandD } from 'evogram'
|
|
2
|
+
import { CommandContext } from 'evogram/lib/migrated'
|
|
3
|
+
import { Client, DepositConfig } from '../../Client'
|
|
4
|
+
import { GetWithdrawalCommand } from './GetWithdrawal.command'
|
|
5
5
|
|
|
6
6
|
@CommandD({ name: 'ewithdrawal' })
|
|
7
7
|
export class AdminWithdrawalCommand extends Command {
|
|
@@ -32,32 +32,24 @@ export class AdminWithdrawalCommand extends Command {
|
|
|
32
32
|
title: '🔒 Подтверждение реквизитов',
|
|
33
33
|
text: `В целях безопасности вывод средств разрешен только после подтверждения ваших реквизитов. Для этого необходимо совершить пополнение счета с того же платежного метода, который вы указали для вывода. Это разовая процедура, которая помогает нам убедиться, что вы являетесь владельцем указанных реквизитов.\n\nЕсли у вас возникли сложности — обратитесь в <a href="https://t.me/${config.support.username}">тех. поддержку</a>`,
|
|
34
34
|
},
|
|
35
|
-
]
|
|
35
|
+
]
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
context: CommandContext,
|
|
42
|
-
@CommandArgument('id') id: string,
|
|
43
|
-
@CommandArgument('decision', ({ value }) => value === '1') decision: boolean,
|
|
44
|
-
@CommandArgument('template?') template: number,
|
|
45
|
-
@CommandArgument('confirm?') confirm: boolean
|
|
46
|
-
) {
|
|
47
|
-
const withdrawal = await GetWithdrawalCommand.getWithdrawal(id);
|
|
48
|
-
if (!AdminWithdrawalCommand.logMessages[id as any]) AdminWithdrawalCommand.logMessages[id as any] = context;
|
|
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) {
|
|
39
|
+
const withdrawal = await GetWithdrawalCommand.getWithdrawal(id)
|
|
40
|
+
if (withdrawal.status !== 'pending') throw new Error('Заявка уже обработана')
|
|
49
41
|
|
|
50
42
|
const withdrawalFormattedID = Math.floor(Math.random() * 500_000_000 + 500_000_000)
|
|
51
43
|
.toString(36)
|
|
52
|
-
.toUpperCase()
|
|
53
|
-
|
|
44
|
+
.toUpperCase()
|
|
45
|
+
context.user.id = withdrawal.user
|
|
46
|
+
const config = Client.config(context)
|
|
54
47
|
|
|
55
|
-
const mammoth = await config.API.get(`/projects/mammoths/${withdrawal.user}`).then((x) => x.data)
|
|
56
|
-
|
|
57
|
-
const client = await config.getClient(mammoth.mirror.mirror.token);
|
|
48
|
+
const mammoth = await config.API.get(`/projects/mammoths/${withdrawal.user}`).then((x) => x.data)
|
|
49
|
+
const client = await config.getClient(mammoth.mirror.mirror.token)
|
|
58
50
|
|
|
59
51
|
if (decision) {
|
|
60
|
-
await AdminWithdrawalCommand.approve(withdrawal.id)
|
|
52
|
+
await AdminWithdrawalCommand.approve(withdrawal.id)
|
|
61
53
|
|
|
62
54
|
// prettier-ignore
|
|
63
55
|
client.api.sendPhoto({
|
|
@@ -92,38 +84,37 @@ export class AdminWithdrawalCommand extends Command {
|
|
|
92
84
|
id,
|
|
93
85
|
decision: false,
|
|
94
86
|
template: i,
|
|
87
|
+
logId,
|
|
95
88
|
},
|
|
96
89
|
},
|
|
97
90
|
]),
|
|
98
|
-
[{ text: 'Пропустить этап', command: AdminWithdrawalCommand, payload: { id, decision: false, template: null, confirm: true } }],
|
|
91
|
+
[{ text: 'Пропустить этап', command: AdminWithdrawalCommand, payload: { id, decision: false, template: null, confirm: true, logId } }],
|
|
99
92
|
],
|
|
100
93
|
},
|
|
101
94
|
}
|
|
102
|
-
)
|
|
95
|
+
)
|
|
103
96
|
}
|
|
104
97
|
|
|
105
98
|
if (!confirm) {
|
|
106
99
|
return context.sendFormatted(
|
|
107
100
|
{
|
|
108
101
|
noPhoto: true,
|
|
109
|
-
header: `<blockquote><b>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${
|
|
110
|
-
AdminWithdrawalCommand.getRejectedMessages(config)[template].text
|
|
111
|
-
}`,
|
|
102
|
+
header: `<blockquote><b>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${AdminWithdrawalCommand.getRejectedMessages(config)[template].text}`,
|
|
112
103
|
},
|
|
113
104
|
{
|
|
114
105
|
reply_markup: {
|
|
115
106
|
inline_keyboard: [
|
|
116
107
|
[
|
|
117
|
-
{ text: '‹ Назад', command: AdminWithdrawalCommand, payload: { id, decision, template: undefined } },
|
|
118
|
-
{ text: 'Продолжить ›', command: AdminWithdrawalCommand, payload: { id, decision, template, confirm: true } },
|
|
108
|
+
{ text: '‹ Назад', command: AdminWithdrawalCommand, payload: { id, decision, template: undefined, logId } },
|
|
109
|
+
{ text: 'Продолжить ›', command: AdminWithdrawalCommand, payload: { id, decision, template, confirm: true, logId } },
|
|
119
110
|
],
|
|
120
111
|
],
|
|
121
112
|
},
|
|
122
113
|
}
|
|
123
|
-
)
|
|
114
|
+
)
|
|
124
115
|
}
|
|
125
116
|
|
|
126
|
-
await AdminWithdrawalCommand.reject(id)
|
|
117
|
+
await AdminWithdrawalCommand.reject(id)
|
|
127
118
|
|
|
128
119
|
// prettier-ignore
|
|
129
120
|
const msg = await client.api.sendPhoto({
|
|
@@ -143,29 +134,19 @@ export class AdminWithdrawalCommand extends Command {
|
|
|
143
134
|
});
|
|
144
135
|
|
|
145
136
|
if (template !== null) {
|
|
146
|
-
msg.reply(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
parse_mode: 'HTML',
|
|
152
|
-
reply_markup: { inline_keyboard: [[{ text: '👨💻 Тех. поддержка', url: `https://t.me/${config.support.username}` }]] },
|
|
153
|
-
}
|
|
154
|
-
);
|
|
137
|
+
msg.reply(`<blockquote>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</blockquote>\n\n${AdminWithdrawalCommand.getRejectedMessages(config)[template].text}`, {
|
|
138
|
+
parse_mode: 'HTML',
|
|
139
|
+
reply_markup: { inline_keyboard: [[{ text: '👨💻 Тех. поддержка', url: `https://t.me/${config.support.username}` }]] },
|
|
140
|
+
})
|
|
155
141
|
}
|
|
156
142
|
}
|
|
157
143
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
144
|
+
const log = await config.API.get(`/mammoths/logs/${logId}`).then((x) => x.data)
|
|
145
|
+
await config.API.put(`/mammoths/logs/${logId}`, {
|
|
146
|
+
title: decision ? 'Одобренная заявка на вывод средств' : 'Отклоненная заявка на вывод средств',
|
|
147
|
+
message: {
|
|
148
|
+
message: log.message.message + (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' : '\n\n<b>Заявка на вывод средств была успешно отклонена ☑️</b>'),
|
|
163
149
|
},
|
|
164
|
-
|
|
165
|
-
parse_mode: undefined,
|
|
166
|
-
text: context.text + (decision ? '\n\nЗаявка на вывод средств была успешно обработана ☑️' : '\n\nЗаявка на вывод средств была успешно отклонена ☑️'),
|
|
167
|
-
entities: context.entities,
|
|
168
|
-
}
|
|
169
|
-
);
|
|
150
|
+
})
|
|
170
151
|
}
|
|
171
152
|
}
|