Search code examples
pythontelegramtelegram-botpython-telegram-bot

How to move from one set of buttons to another with pytelegrambotapi


I want to implement moving from one set of buttons to another in telegram bot for each user separately, like at the screenshots below, I clicked button with text "Ответы на вопросы" and I was moved to another set of buttons

enter image description here

enter image description here

Here is problem, that for each user state about buttons have to store separately. Now I have only one idea how to implement this: to store user-id and state in key-value db.

Are there another solutions to solve this problem more simple, maybe with just resources of pytelegrambotapi? And changes of state can be implemented with just automatons or there are another ideas?


Solution

  • There is no finite state machine implemented in pytelegrambotapi.

    To work properly with user's state, you should use the aiogram framework instead of telebot.

    You can find a basic example of using FSM here.