I
I
Ivan2021-12-16 17:10:03
JavaScript
Ivan, 2021-12-16 17:10:03

How to process incoming message in Telegram bot api?

Hello! Please tell me how to process the incoming message. I don't understand at all.
It works like this:
The bot sends me a message "Enter a stop phrase".
I send something in the message to the bot, for example "boiler".
My message is, in this case, the "boiler" must be passed to the AutoBan.add function.

module.exports = async function(bot, message, query) {
if (query.data === "wordsban") {
await message.send("Введите стоп фразу");
let stop = ЧЕМУ????
await AutoBan.add(stop);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kapp1, 2021-12-18
@kapp1

I don't know what lib you write in, but
messages have an ID so you can check previous messages for command content.
For example,
user - /wordsban // message id 5
bot - enter the word // message id 6
user boiler // message id 7
here you check the logic, if the user entered /wordsban two IDs ago, then the content of the current message must be processed.
This is a bad mechanic, it’s easier to ask to enter a word ban according to the wordsban principle: word1 word2 and catch such messages through a regular expression and parse the string by space

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question