A
A
apiwi2021-03-25 00:09:04
Python
apiwi, 2021-03-25 00:09:04

How to make transition from def back(call): to search(message)?

There is a telegram bot with Inline buttons, I need to be redirected to def search(message) after pressing the button:

@bot.message_handler(content_types=['text'])
def echo_all(message):
    pass
def search(message):
    print("молодец")
#СЮДА НУЖНО ПЕРЕЙТИ ИЗ call.data == '16-20'
@bot.callback_query_handler(func=lambda call: True)
def callback_query(call):
elif call.data == "search":
        bot.delete_message(call.message.chat.id, call.message.message_id)
        kb = InlineKeyboardMarkup(row_width = 1)
        kb.add(InlineKeyboardButton("16-20", callback_data="16-20"))
        kb.add(InlineKeyboardButton("21-25", callback_data="21-25"))
        kb.add(InlineKeyboardButton("26-30", callback_data="26-30"))
        kb.add(InlineKeyboardButton("30 +", callback_data="30 +"))
        bot.send_message(id, "Выберите возрастную категорию:",reply_markup = kb)

elif call.data == '16-20':
      #ТУТ НУЖНО ПЕРЕЙТИ НА def search(message)


Tried search(message), search(call.message) doesn't work, please help.
bot.register_next_step_handler(call.message, search) Not suitable, I need the function to be called immediately

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