A
A
Anatoly Belousov2021-05-08 11:22:52
Python
Anatoly Belousov, 2021-05-08 11:22:52

Problem with bot.register_next_step_handler?

The but1_2 function accepts a YES or NO answer, if YES then it should return several functions higher, if NO then it goes further to the next function, but there is some kind of defect and until the bot sends one message, bot.register_next_step_handler will not work. What to do prompt?

def func_but1(message):
    #набор команд
    bot.register_next_step_handler(message, but1_1)

def but1_1(message):
    #набор команд
    bot.register_next_step_handler(message, but1_2)

def but1_2(message):
    start = message.text.lower()
    if start == 'да':
        bot.send_message(message.chat.id, 'Напиши ОДНО любое сообщение') #Пришлось добавить чтоб человек понимал
        bot.register_next_step_handler(message, func_but1)               # func_but1 находиться выше, через одну функцию 
    elif start == 'нет':
        bot.send_message(message.chat.id, 'Напиши ОДНО любое сообщение') #Пришлось добавить чтоб человек понимал
        bot.register_next_step_handler(message, result_1)                #result_1 идёт следующей, сразу ниже

def result_1(message):
    #набор команд

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-05-08
@no_name_774

Handlers are not attached to anything.

sent = bot.send_message(message.chat.id, 'Напиши ОДНО любое сообщение') #Пришлось добавить чтоб человек понимал
bot.register_next_step_handler(sent, func_but1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question