Answer the question
In order to leave comments, you need to log in
How to set the sequence of handlers when creating a telegram bot [pyTelegramBotAPI]?
Good afternoon!
I can't figure out how to set the handler sequence.
How the bot works:
1) /start
2) select a category: games, books, music.
3) Write a title. (It doesn't matter what the person writes here, the answer is the same.)
4) thanks for contacting!
In the code itself, the first handler contains the category "Games" (if you start communicating with the bot with the word "Games", then there are no problems with the cycle), and if you write "Books" or "Music" to the bot, the bot immediately replies "Thank you for contacting ".
Please tell me how to implement this cycle correctly so that messages to the bot are not intercepted only by the first handler? (Added screenshot)
Answer the question
In order to leave comments, you need to log in
All except the 1st message - text. The text must be processed by one handler. Already in it you need to determine what text the user specified.
Concerning sequence - implement session storage for each user. You can start with a simple dictionary user_id => step_number. It just increases the counter of successful steps after the bot answers each one and check in your handler for the text to understand what the user's question is now and what to answer
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question