R
R
rsoinvi2018-10-26 12:59:27
JavaScript
rsoinvi, 2018-10-26 12:59:27

How to make a bot poll in telegram?

The task is to write a bot that will ask questions, thereby writing the answers to a variable and send them to the channel at the end.
I write on telegraf framework

var name, age

 function askName(c){
   c.reply('Введите имя')
   bot.on('text', (c)=>{
      name = c.message.text
      if(name){
         function(askAge)
      }
   })
}

function askAge(c){
   c.reply('Введите год')
   bot.on('text', (c)=>{
      age = c.message.text
   })
}

function askName(ctx)

After entering the year, the bot on function is triggered again and displays askAge?
How to interrupt the function after the user has sent 1 message to the bot?

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