D
D
Dazaiamur2022-03-18 15:02:07
Python
Dazaiamur, 2022-03-18 15:02:07

Error with InlinKeyboard What is the problem?

Command error itself) aiogram.utils.exceptions.BadRequest: Can't parse inline keyboard button: can't find field "text"

Code

@dp.callback_query_handler(lambda c: c.data and c.data.startswith ('btn'))
async def process_callback_kb1btn1(callback_query: types.CallbackQuery):
    code = callback_query.data[-1]
    if code.isdigit():
        code = int(code)
    if code == 2:
        await bot.answer_callback_query(callback_query.id, text='Нажата вторая кнопка')
    elif code == 5:
        await bot.answer_callback_query(
            callback_query.id,
            text="Нажата кнопка с номером 5", show_alert=True)
    else:
        await bot.answer_callback_query(callback_query.id)
    await bot.send_message(callback_query.from_user.id, f'Нажата инлайн кнопка! code={code}')
@dp.message_handler(commands=['2'])
async def process_command_2(message: types.Message):
    await message.reply("Отправляю все возможные кнопки", reply_markup=kb_client)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question