I
I
Igor Mironov2021-11-16 16:09:25
Python
Igor Mironov, 2021-11-16 16:09:25

Development of TelegramBot in Python. Is it possible to add a property to the callback_query_handler handler so that it can handle more than 1 inlineBaton?

Now @bot.callback_query_handler(lambda first: first.data == "magnit") only handles "magnit", how can I make it handle all inlines?

@bot.callback_query_handler(lambda first: first.data == "magnit")
def callback_inline(call):
    try:
        if call.message:
            if call.data == 'magnit':
                bot.send_message(call.message.chat.id, 'Выберите подкатегорию.')
            elif call.data == 'mac':
                bot.send_message(call.message.chat.id, 'Выберите подкатегорию.')
            elif call.data == 'kfc':
                bot.send_message(call.message.chat.id, 'Выберите подкатегорию.')
    except Exception as e:
        print(e)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-11-16
@papeygovna71

@bot.callback_query_handler(lambda first: True)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question