X
X
XenK2016-07-10 13:02:02
JavaScript
XenK, 2016-07-10 13:02:02

Telegram bot on NodeJS?

I use this library node-telegram-bot-api , via polling.
There was a question how to make that after entering / setname , the bot prompted to enter a name. If, for example, within 30 seconds, the user did not enter anything, then the command was canceled. How can I do that?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
#
#algooptimize #bottize, 2016-07-10
@user004

What exactly is the problem ?, it seems like the solution is obvious, suggest the user to enter a name and after 30 seconds they do not process it anymore and display a warning to the user if they want.

A
Anton, 2016-07-10
@SPAHI4

this lib has this type
https://github.com/mdibaiee/node-telegram-api/wiki...

V
Vitaly Stolyarov, 2016-07-10
@Ni55aN

It would be more correct to enter a name next to the command itself
. Although it is possible like this:

var stateSetName = false;

bot.onText(/\(.*)/, function (msg, match) {

if(!stateSetName)return;

var name = match[1];
});

bot.onText(/\/setname/, function (msg, match) {
  
  var fromId = msg.from.id;
  bot.sendMessage(fromId, "Введите имя");
stateSetName =true;

 setTimeout(function(){   bot.sendMessage(fromId, "Отмена!"); stateSetName =false;},30000);
});

but ideally, similar with message chains should be done through states

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question