0

Python 3.13.2, pyTelegramBotAPI-4.27.0, Windows 10

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.

Perhaps there is a way to debug this?

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"

5
  • I don't know too much about telebot, im more of an aiogram user but from what I know shouldn't you answer the callback query with something like call.answer()? But either way, the fact that your print statement isn't being executed means that that entire callback function isn't being executed so it must be something to do with the decorator Commented May 3 at 21:56
  • It worked perfect some time ago and stopped to work recently for unknown reason. I definitely did not change this area, so should be related to something else. For the moment I can not call nothing as event just not triggered by decorator. Commented May 4 at 16:11
  • It could be due to a version change then, maybe you upgraded to a later version of telebot which now makes your code obsolete? Commented May 5 at 1:18
  • Perhaps, I am newbie and have no ideas for the moment. Perhaps there is a way to debug. All other handlers and bot code works fine. Commented May 5 at 6:09
  • Issue resolved (as per advise from another site) by reissuing Bot token. Incredible, but Inline buttons are back operational. Thanks for All! Commented May 5 at 18:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.