T
T
Tribian2022-03-11 17:36:38
Python
Tribian, 2022-03-11 17:36:38

How to determine what is in the callback (aiogram)?

The bot generates buttons in the keyboard according to data from the database (names of people).
It is necessary to catch the user's choice (which button was clicked).
Now the callback is working, but I don't understand which button was pressed.

for item in list_button_name:
            buttons_list.append([InlineKeyboardButton(text = item, callback_data = item)])
        keyboard_inline_buttons = InlineKeyboardMarkup(inline_keyboard = buttons_list)

@dp.callback_query_handler(text = list_button_name)
        async def process_callback_name(callback_query: types.CallbackQuery):
            await bot.answer_callback_query(callback_query.id)
            await bot.send_message(callback_query.from_user.id, 'Вы выбрали имя ->' )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2022-03-11
@Tribian

check what you have in callback_query.data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question