Telegram bot's step handler not working in python if statement

44 views Asked by At

I am creating a telegram bot and know a quiet bit. There is no problem with using "register_next_step_handler" to go to another message handler and process it. But if I want to set an if statement and choose to go to different steps based on different conditions, it stops working. For a simple example, when the bot goes to the following function, it prints "1" or "2" based on the condtion, but does not run the rest and does not go to the next step. The same thing happens if you want to use this "register_next_step_handler" in "for loop"

def process_decision_step(message):
    if condition1:
        print('1')
        bot.register_next_step_handler(message, process_first_step)
    else:
        print("2")
        bot.register_next_step_handler(message, process_second_step)

Should I use a complementary function on handlers, like "bot.enable_save_next_step_handlers()" or "bot.load_next_step_handlers()"?

0

There are 0 answers