pythontelegramtelegram-botpython-telegram-botpy-telegram-bot-api

I make a telegram bot with telebot in python, but I got an error that I have textbutton, although I have use InlineKeyboardButton, why?


thats my code in the image

thats cut of my code:

keyboard = types.InlineKeyboardMarkup(row_width=2) # вывод кнопок в 1 колонку
btn_1 = types.InlineKeyboardButton(bookmarks_categories[0], callback_data=0)
btn_2 = types.InlineKeyboardButton(bookmarks_categories[1], callback_data=1)
btn_3 = types.InlineKeyboardButton(bookmarks_categories[2], callback_data=2)
keyboard.add(btn_1,btn_2,btn_3,btn_4,btn_5,btn_6,btn_7,btn_8,btn_9,btn_10,btn_11,btn_12,btn_13,btn_14,btn_15,btn_16,btn_17)
bot.send_message(message.chat.id, 'Вывод inline-клавиатуры', reply_markup=keyboard)

thats my error:

2021-08-28 00:11:29,741 (__init__.py:652 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse inline keyboard button: Text buttons are unallowed in the inline keyboard"

how can I solve this problem?


Solution

  • you can check this solution, I have done a project by multiple keyboards such as inline_keyboards and Reply_keyboards, I used telegram library

    from telegram import (InlineKeyboardButton, InlineKeyboardMarkup)
    

    for inline keyboards buttons you can identify keyboard buttons first in this way:

    buttons = [
        [
            InlineKeyboardButton(text=bookmarks_categories[0],callback_data=0),
            InlineKeyboardButton(text=bookmarks_categories[1],callback_data=1),
        ],
    ]
    

    then identify your keyboard like this:

    keyboard = InlineKeyboardMarkup(buttons)