I
I
iris_duty_20202021-04-30 08:12:36
API
iris_duty_2020, 2021-04-30 08:12:36

Autodonate connection?

In general, I wanted to implement an auto-donate in the VKontakte bot. Wrote sample code, but something went wrong. The code:

function donateLink(options) {

    let payId = options.id;
    let Field1 = options.field1;
    let Field2 = options.field2;
  let secretKey = 'jksfacjc';
  let currency = 'RUB';
  let merchId = 309922;
  let sign = md5(`309922:${options.amount}:jksfacjc:RUB:tovar`);
  const url = `https://www.free-kassa.ru/merchant/cash.php?oa=${options.amount}&i=&m=${merchId}&go_2pay=1&wt=v3&form_id=1686450&s={sign}`;

  return url;
}

updates.hear(/^(?:тест донат)\s(.*)?/i, async message => {
   let don_currency = donateLink
   let currencyy = await vk.api.utils.getShortLink({ url: donateLink });
   return message.send(`Вы покупаете ${message.$match[1]} печенек\n\n Ссылка для оплаты ${currencyy.short_url}`)
   });


After entering the command "test donate {amount}" - the bot ignores, and an error appears in the console:
Message received: test donate 200 | 52 | user: @id598958885 |

{ ExecuteError: Code #100 - One of the parameters specified was missing or invalid: url is undefined
at request.resolve.errors.map.error (/root/manager/node_modules/vk-io/lib/index.js:1240: 62)
at Array.map ()
at API.callMethod (/root/manager/node_modules/vk-io/lib/index.js:1240:49)
at process._tickCallback (internal/process/next_tick.js:68:7 ) code: 100, name: 'ExecuteError', method: 'utils.getShortLink' }

Those. it can't find the url to shorten. So there is an error somewhere in the function, but I don't understand where. The function at the end returns the "url" variable... Help please

---

I also tried this:

function donateLink(options) {

    let payId = options.id;
    let Field1 = options.field1;
    let Field2 = options.field2;
  let secretKey = 'jksfacjc';
  let currency = 'RUB';
  let merchId = 309922;
  let sign = md5(`309922:${options.amount}:jksfacjc:RUB:tovar`);
  const url = `https://www.free-kassa.ru/merchant/cash.php?oa=${options.amount}&i=&m=${merchId}&go_2pay=1&wt=v3&form_id=1686450&s={sign}`;

  return url;
}

updates.hear(/^(?:тест донат)\s(.*)?/i, async message => {
   let don_currency = donateLink
   let currencyy = await vk.api.utils.getShortLink({ url: don_currency});
   return message.send(`Вы покупаете ${message.$match[1]} печенек\n\n Ссылка для оплаты ${currencyy.short_url}`)
   });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question