S
S
sir-coffee2021-08-27 18:03:13
Python
sir-coffee, 2021-08-27 18:03:13

Python-TelegramBot | Why does telebot consider InlineKeyboardButton to be TextButtons?

Error itself:
2021-08-27 23:59:40,272 (__init__.py:652 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccess
ful. Error code: 400. Description: Bad Request: can't parse inline keyboard button: Text buttons are unallowed in
the inline keyboard"


Here is the code

@bot.message_handler(commands=['start'])
def get_text_messages(message):
        #commands = message.text.split()
        #print(commands)
        url = message.text
        print(url)
        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)
        btn_4 = types.InlineKeyboardButton(bookmarks_categories[3], callback_data=3)
        btn_5 = types.InlineKeyboardButton(bookmarks_categories[4], callback_data=4)
        btn_6 = types.InlineKeyboardButton(bookmarks_categories[5], callback_data=5)
        btn_7 = types.InlineKeyboardButton(bookmarks_categories[6], callback_data=6)
        btn_8 = types.InlineKeyboardButton(bookmarks_categories[7], callback_data=7)
        btn_9 = types.InlineKeyboardButton(bookmarks_categories[8], callback_data=8)
        btn_10 = types.InlineKeyboardButton(bookmarks_categories[9], callback_data=9)
        btn_11 = types.InlineKeyboardButton(bookmarks_categories[10], callback_data=10)
        btn_12 = types.InlineKeyboardButton(bookmarks_categories[11], callback_data=11)
        btn_13 = types.InlineKeyboardButton(bookmarks_categories[12], callback_data=12)
        btn_14 = types.InlineKeyboardButton(bookmarks_categories[13], callback_data=13)
        btn_15 = types.InlineKeyboardButton(bookmarks_categories[14], callback_data=14)
        btn_16 = types.InlineKeyboardButton(bookmarks_categories[15], callback_data=15)
        btn_17 = types.InlineKeyboardButton(bookmarks_categories[16], callback_data=16)
        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)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sir-coffee, 2021-08-27
@sir-coffee

I solved the problem, it turns out callback_data cannot be 0.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question