nexushub-commands 2.5.0 → 2.5.2

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.
@@ -86,15 +86,17 @@ let DepositCommand = DepositCommand_1 = class DepositCommand extends evogram_1.C
86
86
  if (method === 'card' && config.currency.toUpperCase() === 'RUB') {
87
87
  const availableMyRequisites = (yield config.API.get('/myrequisites')).data;
88
88
  const myRequisites = (yield config.API.get(`/aggregators/myrequisites`)).data;
89
+ const _minAmount = availableMyRequisites.sort((a, b) => a.minAmount - b.minAmount)[0].minAmount;
90
+ const minAmount = myRequisites.minAmount > _minAmount ? myRequisites.minAmount : _minAmount;
89
91
  if (availableMyRequisites.length > 0 && myRequisites.enabled) {
90
92
  return context.sendFormatted({
91
93
  designImages: ['deposit-no-requisite', 'deposit'],
92
94
  photo: config.images.deposit,
93
95
  header: '<b>❗️К сожалению, сейчас нет доступных реквизитов для оплаты.</b>',
94
- footer: `<i>ℹ️ На данный момент есть доступные реквизиты для суммы, начинающейся от ${yield myRequisites.minAmount.convert({ from: 'RUB', to: config.currency })}</i>`,
96
+ footer: `<i>ℹ️ На данный момент есть доступные реквизиты для суммы, начинающейся от ${yield minAmount.convert({ from: 'RUB', to: config.currency })}</i>`,
95
97
  }, {
96
98
  reply_markup: {
97
- inline_keyboard: [[{ text: `💸 Пополнить на ${yield myRequisites.minAmount.convert({ from: 'RUB', to: config.currency })}`, command: DepositCommand_1, payload: { method: 'card', deposit: myRequisites.minAmount } }]],
99
+ inline_keyboard: [[{ text: `💸 Пополнить на ${yield minAmount.convert({ from: 'RUB', to: config.currency })}`, command: DepositCommand_1, payload: { method: 'card', deposit: minAmount } }]],
98
100
  },
99
101
  });
100
102
  }
@@ -267,8 +269,12 @@ tslib_1.__decorate([
267
269
  })).text;
268
270
  }),
269
271
  }, (0, evogram_1.numberValidator)({ allowFloat: true, min: 0 }), (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ value, context, validateArgs }) {
272
+ var _b, _c;
270
273
  const config = Client_1.Client.config(context);
271
- const maxDeposit = yield config.API.get('/config/maxDepositInService').then((x) => x.data.value);
274
+ const availableMyRequisites = (yield config.API.get('/myrequisites')).data;
275
+ const maxDeposit1 = Number((_c = (_b = availableMyRequisites === null || availableMyRequisites === void 0 ? void 0 : availableMyRequisites.sort((a, b) => a.maxAmount - b.maxAmount)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.maxAmount);
276
+ const maxDeposit2 = Number(yield config.API.get('/config/maxDepositInService').then((x) => x.data.value));
277
+ const maxDeposit = maxDeposit1 > maxDeposit2 ? maxDeposit1 : maxDeposit2;
272
278
  const depositAmount = yield value.convert({ from: config.currency, to: 'RUB' });
273
279
  if (depositAmount > maxDeposit && validateArgs.method !== 'cryptoWallet')
274
280
  throw new Error(`Пополнение, более чем на ${yield maxDeposit.convert({ from: 'RUB', to: config.currency })}, доступно только через <a href="t.me/{{ ${config.support.username} }}">тех. поддержку</a>`);
@@ -20,7 +20,7 @@ let RegistrationCommand = RegistrationCommand_1 = class RegistrationCommand exte
20
20
  }
21
21
  execute(context) {
22
22
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
- var _a;
23
+ var _a, _b, _c, _d, _e;
24
24
  const config = Client_1.Client.config(context);
25
25
  if (/\/(start|registration) \d+/.test(context.text) || Number(context.text))
26
26
  context.user.userDB.payload.refCode = Number((_a = /(\/(start|registration) )?(\d+)/.exec(context.text)) === null || _a === void 0 ? void 0 : _a[3]);
@@ -31,7 +31,7 @@ let RegistrationCommand = RegistrationCommand_1 = class RegistrationCommand exte
31
31
  body: [
32
32
  {
33
33
  title: `🎉 Привет, {{ ${context.user.fullname} }}!`,
34
- data: [[`<a href="${config.agreement}">Политика и условия пользования</a>`]],
34
+ data: [[`<a href="${((_b = context.state.mirror) === null || _b === void 0 ? void 0 : _b.projectMirror.userAgreement) || ((_e = (_d = (_c = context.state) === null || _c === void 0 ? void 0 : _c.settings) === null || _d === void 0 ? void 0 : _d.find((x) => x.name === 'userAgreement')) === null || _e === void 0 ? void 0 : _e.value) || config.agreement}">Политика и условия пользования</a>`]],
35
35
  },
36
36
  ],
37
37
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -157,8 +157,12 @@ export class DepositCommand extends Command {
157
157
  numberValidator({ allowFloat: true, min: 0 }),
158
158
  async ({ value, context, validateArgs }) => {
159
159
  const config = Client.config(context)
160
+ const availableMyRequisites = (await config.API.get('/myrequisites')).data
161
+
162
+ const maxDeposit1 = Number(availableMyRequisites?.sort((a: any, b: any) => a.maxAmount - b.maxAmount)?.[0]?.maxAmount)
163
+ const maxDeposit2 = Number(await config.API.get('/config/maxDepositInService').then((x) => x.data.value))
164
+ const maxDeposit = maxDeposit1 > maxDeposit2 ? maxDeposit1 : maxDeposit2
160
165
 
161
- const maxDeposit = await config.API.get('/config/maxDepositInService').then((x) => x.data.value)
162
166
  const depositAmount = await value.convert({ from: config.currency, to: 'RUB' })
163
167
 
164
168
  if (depositAmount > maxDeposit && validateArgs.method !== 'cryptoWallet') throw new Error(`Пополнение, более чем на ${await maxDeposit.convert({ from: 'RUB', to: config.currency })}, доступно только через <a href="t.me/{{ ${config.support.username} }}">тех. поддержку</a>`)
@@ -241,6 +245,8 @@ export class DepositCommand extends Command {
241
245
  if (method === 'card' && config.currency.toUpperCase() === 'RUB') {
242
246
  const availableMyRequisites = (await config.API.get('/myrequisites')).data
243
247
  const myRequisites = (await config.API.get(`/aggregators/myrequisites`)).data
248
+ const _minAmount = availableMyRequisites.sort((a: any, b: any) => a.minAmount - b.minAmount)[0].minAmount
249
+ const minAmount = myRequisites.minAmount > _minAmount ? myRequisites.minAmount : _minAmount
244
250
 
245
251
  if (availableMyRequisites.length > 0 && myRequisites.enabled) {
246
252
  return context.sendFormatted(
@@ -248,11 +254,11 @@ export class DepositCommand extends Command {
248
254
  designImages: ['deposit-no-requisite', 'deposit'],
249
255
  photo: config.images.deposit,
250
256
  header: '<b>❗️К сожалению, сейчас нет доступных реквизитов для оплаты.</b>',
251
- footer: `<i>ℹ️ На данный момент есть доступные реквизиты для суммы, начинающейся от ${await myRequisites.minAmount.convert({ from: 'RUB', to: config.currency })}</i>`,
257
+ footer: `<i>ℹ️ На данный момент есть доступные реквизиты для суммы, начинающейся от ${await minAmount.convert({ from: 'RUB', to: config.currency })}</i>`,
252
258
  },
253
259
  {
254
260
  reply_markup: {
255
- inline_keyboard: [[{ text: `💸 Пополнить на ${await myRequisites.minAmount.convert({ from: 'RUB', to: config.currency })}`, command: DepositCommand, payload: { method: 'card', deposit: myRequisites.minAmount } }]],
261
+ inline_keyboard: [[{ text: `💸 Пополнить на ${await minAmount.convert({ from: 'RUB', to: config.currency })}`, command: DepositCommand, payload: { method: 'card', deposit: minAmount } }]],
256
262
  },
257
263
  }
258
264
  )
@@ -27,7 +27,7 @@ export class RegistrationCommand extends Command {
27
27
  body: [
28
28
  {
29
29
  title: `🎉 Привет, {{ ${context.user.fullname} }}!`,
30
- data: [[`<a href="${config.agreement}">Политика и условия пользования</a>`]],
30
+ data: [[`<a href="${context.state.mirror?.projectMirror.userAgreement || context.state?.settings?.find((x: any) => x.name === 'userAgreement')?.value || config.agreement}">Политика и условия пользования</a>`]],
31
31
  },
32
32
  ],
33
33
  },