Answer the question
In order to leave comments, you need to log in
How to call the text input function after processing the callback (clicking on the Inline button)?
I welcome everyone. The task is this: the user needs to fill out a questionnaire. During the survey, the user enters the answers to the questions in text, and also answers the questions by pressing the Inline button. And then a problem arises: after clicking on the button, I cannot forward the message to the step-by-step handler, because it is logically not. Question: how to call a function from the callback handler according to the register_next_step_handler principle?
Example:
def start_questionnaire(message):
bot.send_message(message.from_user.id, 'Введите город проживания')
bot.register_next_step_handler(message, get_town)
def get_town(message):
data_dict = dict
data_dict['town'] = message.text
keyboard = types.InlineKeyboardMarkup(row_width=1)
keyboard.add(types.InlineKeyboardButton(text='Мужской', callback_data='m'),
types.InlineKeyboardButton(text='Женский', callback_data='f'))
bot.send_message(message.from_user.id, 'Укажите свой пол', keyboard)
@bot.callback_query_handler(func=lambda call: True)
def callbacks_worker(call):
if call.data in ['m', 'f']:
# и отсюда должен быть переброс в ф-ю, которая будет принимать значение message.
Answer the question
In order to leave comments, you need to log in
It’s not entirely clear what the problem is, because the call object contains the message object
bot.register_next_step_handler(call.message, <Твоя функция>)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question