S
S
sleep2-night2020-08-26 21:39:24
Node.js
sleep2-night, 2020-08-26 21:39:24

Handling Telegram Bot messages?

I am trying to process a bot message like this:

bot.onText(/\/add/, async (msg) => {
  bot.sendMessage(msg.chat.id, "Добавь ссылку на фото...");
  let link = await getAnswer();
  bot.sendMessage(msg.chat.id, link);
});

async function getAnswer() {
  bot.on("message", (msg) => {
    return msg.text;
  });
}


Accordingly, the bot should give me the message that I wrote and save it in a variable, but it gives an error:
Unhandled rejection Error: ETELEGRAM: 400 Bad Request: message text is empty
    at C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\node-telegram-bot-api\src\telegram.js:284:15
    at tryCatcher (C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\bluebird\js\release\promise.js:729:18)
    at _drainQueueStep (C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\sasha\Desktop\MelqorShopBot v2\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (internal/timers.js:458:21)


Thank you in advance :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-08-26
@Alexandre888

https://stackoverflow.com/questions/55814488/unhan...
isn't it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question