Answer the question
In order to leave comments, you need to log in
Telebot library, inline button has no reaction, how to solve?
markup_inline = types.InlineKeyboardMarkup(row_width=1)
item_cours5 = types.InlineKeyboardButton(text = cours5, callback_data='1')
item_cours6 = types.InlineKeyboardButton(text = cours6, callback_data='2')
item_cours7 = types.InlineKeyboardButton(text = cours7, callback_data='3')
item_cours8 = types.InlineKeyboardButton(text = cours8, callback_data='4')
item_cours9 = types.InlineKeyboardButton(text = cours9, callback_data='5')
markup_inline.add(item_cours5, item_cours6, item_cours7, item_cours8, item_cours9)
I connected the keyboard, everything works fine, it appears under the desired message@bot.callback_query_handler(func = lambda message: True)
def answer(message):
if message.data == '1':
bot.send_message(message.chat.id, "Открываю...")
Here is the inline button handler, as soon as it did not twist, there was no reaction ...
Answer the question
In order to leave comments, you need to log in
no reaction
AttributeError: 'CallbackQuery' object has no attribute 'chat'
print(message)
in the function answer
, you will see that there is no such field as chat
Try this:
keyboard = types.InlineKeyboardMarkup()
rele1 = types.InlineKeyboardButton(text="cours5", callback_data="1")
rele2 = types.InlineKeyboardButton(text="cours6", callback_data="2")
backbutton = types. InlineKeyboardButton(text="Back", callback_data="mainmenu")
keyboard.add(rele1)
keyboard.add(rele2)
keyboard.add(backbutton)
or try removing the quotes in cours
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question