O
O
Odil Davronov2018-08-11 17:57:44
Python
Odil Davronov, 2018-08-11 17:57:44

Bot.register_next_step_handler doesn't work automatically. Why?

Exit the calendar online. The user selects a date, notifications will appear that the date has been selected. But after that, the following code does not run. bot.register_next_step_handler doesn't help. It will work when the user sends something to the bot.

@bot.callback_query_handler(func=lambda call: call.data[0:13] == 'calendar-day-')
def get_day(call):
    chat_id = call.message.chat.id
    saved_date = current_shown_dates.get(chat_id)
    if(saved_date is not None):
        day=call.data[13:]
        date = datetime.datetime(int(saved_date[0]),int(saved_date[1]),int(day))
        msg = bot.send_message(chat_id, str(date))
        bot.answer_callback_query(call.id, text="Дата выбрана")
        bot.register_next_step_handler(msg, person)

    else:
        #Do something to inform of the error
        pass
    bot.register_next_step_handler(msg, person)

def person(message):
    keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=0.2)
    keyboard.add(*[types.KeyboardButton(name) for name in ["1", "2", "3", "4", "5", "6"]])
    keyboard.add(*[types.KeyboardButton(name) for name in ["Главное меню"]])
    mess = bot.send_message(message.chat.id, "Укажите количество персон:", reply_markup=keyboard)
    bot.register_next_step_handler(mess, answer)

Now if the user writes something, then def person(message):
And I need that he immediately (automatically) earned after the notification "Date selected".
How to fix, Help! Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question