nexushub-commands 1.9.0 → 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.
@@ -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: `https://catbox.moe/user/api.php`,
40
- maxBodyLength: Infinity,
39
+ url: `http://localhost:6234/images/upload`,
41
40
  headers: {
42
- 'Content-Type': 'application/x-www-form-urlencoded',
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('Не удалось загрузить фотографию, попробуйте позже');
@@ -48,6 +48,7 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
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
54
  const client = yield config.getClient(mammoth.mirror.mirror.token);
@@ -130,8 +131,7 @@ let AdminWithdrawalCommand = AdminWithdrawalCommand_1 = class AdminWithdrawalCom
130
131
  yield config.API.put(`/mammoths/logs/${logId}`, {
131
132
  title: decision ? 'Одобренная заявка на вывод средств' : 'Отклоненная заявка на вывод средств',
132
133
  message: {
133
- message: log.message.message +
134
- (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' : '\n\n<b>Заявка на вывод средств была успешно отклонена ☑️</b>'),
134
+ message: log.message.message + (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' : '\n\n<b>Заявка на вывод средств была успешно отклонена ☑️</b>'),
135
135
  },
136
136
  });
137
137
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -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: `https://catbox.moe/user/api.php`,
44
- maxBodyLength: Infinity,
39
+ url: `http://localhost:6234/images/upload`,
45
40
  headers: {
46
- 'Content-Type': 'application/x-www-form-urlencoded',
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,30 +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
- public async execute(
39
- context: CommandContext,
40
- @CommandArgument('id') id: string,
41
- @CommandArgument('decision', ({ value }) => value === '1') decision: boolean,
42
- @CommandArgument('template?') template: number,
43
- @CommandArgument('confirm?') confirm: boolean,
44
- @CommandArgument('logId') logId: number
45
- ) {
46
- const withdrawal = await GetWithdrawalCommand.getWithdrawal(id);
47
- if (withdrawal.status !== 'pending') throw new Error('Заявка уже обработана');
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('Заявка уже обработана')
48
41
 
49
42
  const withdrawalFormattedID = Math.floor(Math.random() * 500_000_000 + 500_000_000)
50
43
  .toString(36)
51
- .toUpperCase();
52
- const config = Client.config(context);
44
+ .toUpperCase()
45
+ context.user.id = withdrawal.user
46
+ const config = Client.config(context)
53
47
 
54
- const mammoth = await config.API.get(`/projects/mammoths/${withdrawal.user}`).then((x) => x.data);
55
- 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)
56
50
 
57
51
  if (decision) {
58
- await AdminWithdrawalCommand.approve(withdrawal.id);
52
+ await AdminWithdrawalCommand.approve(withdrawal.id)
59
53
 
60
54
  // prettier-ignore
61
55
  client.api.sendPhoto({
@@ -98,16 +92,14 @@ export class AdminWithdrawalCommand extends Command {
98
92
  ],
99
93
  },
100
94
  }
101
- );
95
+ )
102
96
  }
103
97
 
104
98
  if (!confirm) {
105
99
  return context.sendFormatted(
106
100
  {
107
101
  noPhoto: true,
108
- header: `<blockquote><b>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${
109
- AdminWithdrawalCommand.getRejectedMessages(config)[template].text
110
- }`,
102
+ header: `<blockquote><b>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</b></blockquote>\n\n${AdminWithdrawalCommand.getRejectedMessages(config)[template].text}`,
111
103
  },
112
104
  {
113
105
  reply_markup: {
@@ -119,10 +111,10 @@ export class AdminWithdrawalCommand extends Command {
119
111
  ],
120
112
  },
121
113
  }
122
- );
114
+ )
123
115
  }
124
116
 
125
- await AdminWithdrawalCommand.reject(id);
117
+ await AdminWithdrawalCommand.reject(id)
126
118
 
127
119
  // prettier-ignore
128
120
  const msg = await client.api.sendPhoto({
@@ -142,26 +134,19 @@ export class AdminWithdrawalCommand extends Command {
142
134
  });
143
135
 
144
136
  if (template !== null) {
145
- msg.reply(
146
- `<blockquote>${AdminWithdrawalCommand.getRejectedMessages(config)[template].title}</blockquote>\n\n${
147
- AdminWithdrawalCommand.getRejectedMessages(config)[template].text
148
- }`,
149
- {
150
- parse_mode: 'HTML',
151
- reply_markup: { inline_keyboard: [[{ text: '👨‍💻 Тех. поддержка', url: `https://t.me/${config.support.username}` }]] },
152
- }
153
- );
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
+ })
154
141
  }
155
142
  }
156
143
 
157
- const log = await config.API.get(`/mammoths/logs/${logId}`).then((x) => x.data);
144
+ const log = await config.API.get(`/mammoths/logs/${logId}`).then((x) => x.data)
158
145
  await config.API.put(`/mammoths/logs/${logId}`, {
159
146
  title: decision ? 'Одобренная заявка на вывод средств' : 'Отклоненная заявка на вывод средств',
160
147
  message: {
161
- message:
162
- log.message.message +
163
- (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' : '\n\n<b>Заявка на вывод средств была успешно отклонена ☑️</b>'),
148
+ message: log.message.message + (decision ? '\n\n<b>Заявка на вывод средств была успешно обработана ☑️</b>' : '\n\n<b>Заявка на вывод средств была успешно отклонена ☑️</b>'),
164
149
  },
165
- });
150
+ })
166
151
  }
167
152
  }