[Python] Python telebot inline buttons do not response for some reason. Button handlers not...

Discussão em 'Python' iniciado por Stack, Maio 3, 2025.

  1. Stack

    Stack Membro Participativo

    Python 3.13.2 pyTelegramBotAPI-4.27.0

    I have a problem with Python telebot inline buttons. It worked fine for a long time, without any problems. At some point it stopped to work. I did not change the code. I tested even basic examples and have the same behavior - handler is not triggered.

    import telebot
    from telebot import types

    API_TOKEN = '0123456789:AaBbCcDdEe'

    bot = telebot.TeleBot(API_TOKEN)

    kb = types.InlineKeyboardMarkup(row_width=1)
    btn_types = types.InlineKeyboardButton(text='label1', callback_data='btn_types')
    kb.add(btn_types)

    @bot.message_handler(commands=['start'])
    def send_welcome(message):
    bot.send_message(message.chat.id, "text", reply_markup=kb)

    @bot.callback_query_handler(func=lambda call: True)
    def answer(call):
    print(call.data)
    if call.data == 'btn_types':
    bot.send_message(call.message.chat.id, "Button clicked")

    if __name__ == '__main__':
    bot.polling(none_stop=True)


    Button shown, but on click nothing happens. At the same time, url inline button works fine. Plain buttons work fine as well...

    What might happen?

    Run bot, /start in Telegram, button shown. On button click, bot should respond with some action. However, nothing happens. In the example provided it should show chat message "Button clicked"

    Continue reading...

Compartilhe esta Página