1

python telegram bot api inlinekeyboardbutton not getting callback_data,

i'm using telebot libray,

this is how i created the buttons

            markup = types.ReplyKeyboardMarkup(row_width=2)
            b1 = types.InlineKeyboardButton("button 1", callback_data='1')
            b2 = types.InlineKeyboardButton('Button 2', callback_data='2')
            markup.add(b1, b2)
            bot.send_message(cid, 'message', reply_markup=markup)

the buttons appear and i can press them but nothing returns to my callback_query_handler

@bot.callback_query_handler(func=lambda call: True)
def callback_button(call):
    try:
        if call.message:
            cid = message.chat.id
            if call.data == '1':
                pass
            elif call.data == '2':
                pass
    except:
        pass

1 Answer 1

2

As it turned out, InlineKeyboardButton objects do not return callback as ReplyKeyboardButton objects.

InlineKeyboardButton are sent as a message and they will appear within the message_handler

Sign up to request clarification or add additional context in comments.

Comments

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.