I'm programming a telegram bot in Python3 using the Telegram bot API. I'm facing the problem of handling requests that need multiple steps to couplet. For example, for an airline search bot:
What can I do?
You need to have a question tree that users can traverse it (you can use a linked list for it and save this tree to the database).
For each question, there is a method that takes some actions (like storing some data in the database) and sends a question/result to the user. Each user has a CurrentState
that contain state of the user in the question tree. The user sent an answer to and the bot will run corresponding method and responds to the user.
method = //Fetch user CurrentState from db e.g. airlineBot.doSomething
method(TelegramMessage)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.