Answer the question
In order to leave comments, you need to log in
How to make telegram bot wait for second message?
The bottom line is that I want to create something like a quest. The person presses the button and the bot must wait for another message and then compare it. I tried to make it call a function when the button is clicked, but it passes the value from message.text there and compares it. A must first wait for another message and then compare them. I would be grateful if you show the method or how to implement it in code
Answer the question
In order to leave comments, you need to log in
Check if there is a message from this user in the database.
If not, then put it there.
If yes, then compare.
The essence of the quest is a finite state machine. which is the same for all users. Accordingly, you just need to implement a "protocol" of passage tied to a specific user. Then the bot, when receiving a message, will always know at what step each specific user is.
Or moving along a directed graph. When you know exactly what step you are on and, for example, use the buttons to display answer options. Then you know exactly how to continue from any step. You can not keep a protocol with reference to users.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question