Search code examples
pythontelegramtelegram-bottelebot

Telebot, Python and InlineKeyboard


Im triyng to make filter inside inlinekeyboard, in short:

    markup = types.InlineKeyboardMarkup()
    button_4 = types.InlineKeyboardButton('Да, все верно', callback_data = 'yes')
    button_5 = types.InlineKeyboardButton('Нет, нужно изменить', callback_data = 'no')
    markup.add(button_4, button_5)
    bot.send_message(message.chat.id, 'Введеные данные верны?', reply_markup = markup)
@bot.callback_query_handler(func = lambda call: True)
def answer(call):
    if call.data == 'yes': 
        print('GOT IT')

but nothing happend, i don't see "GOT IT" in terminal (btw i used it in same code at the begin and it works...)


Solution

  • Try to Print callBack data:

    @bot.message_handler(commands=["start"])
        key = types.InlineKeyboardMarkup()
        key.add(types.InlineKeyboardButton('Да, все верно', callback_data='yes'))
        key.add(types.InlineKeyboardButton('Нет, нужно изменить', callback_data='no'))
        bot.send_message(message.chat.id, 'Введеные данные верны?', reply_markup=markup)
    
    @bot.callback_query_handler(func=lambda call: call.data)
    def answer(call):
        print(call.data)