Answer the question
In order to leave comments, you need to log in
How to implement the order of execution and dependency when creating a TG bot?
how to use the pyTelegramBotAPI library to implement the dependence of one command on another. For example, I want the user to send something like "/send_id" followed by additional information, but at the same time, that additional information is processed only after the command '/send_id' is entered.
How could this be implemented? If it is somewhere in the documentation, just throw a link.
Answer the question
In order to leave comments, you need to log in
You need a state machine implementation.
Simplified, for each user whose event we process, we need to store what state it is in (for example, in your case "initial" or "the /send_id command was sent"). Then, when processing events, you check whether the user is in the desired state.
You can store states in different ways. In the simplest case, if the states are not required to survive the bot restart and do not have additional data, a dictionary of the form "User ID - status code" may suffice.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question