P
P
PegasusPega2022-03-03 05:01:29
API
PegasusPega, 2022-03-03 05:01:29

How to write the user's response to a variable (Bot telegram)?

The user sends the /Enter command, enters text in the next message, the received text is written to a variable. How to organize it on node.js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zagir Majidov, 2022-03-04
@PegasusPega

I still do not understand what kind of library, but I think that 'Telegraf'
Here is the code:

let prev_command = ""

bot.command('test', (ctx) => {
  ctx.reply("Send your text in chat.")
  prev_command = "test"
});

bot.on('text', (ctx) => {
  if (prev_command == "test") {
    ctx.reply(`Ok, your text '${ctx.message.text}'`)
  } else {
    ctx.reply("Sorry, usage commands!")
  }
})

Making this design is easy!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question