N
N
Nikita Shlyakhov2021-04-06 21:32:47
Telegram
Nikita Shlyakhov, 2021-04-06 21:32:47

How to handle inline keyboard inside state aiogram?

I want to process an inline keyboard, with a button to exit the current state to the main menu.
I usually use this syntax

@dp.callback_query_handler()
async def имя(callback_query: types.CallbackQuery):

For handling states
async def имя(message: types.Message, state: FSMContext):
    ...
dp.register_message_handler(имя, state=состояние)

The problem is that, firstly, simply processing the inline keyboard as usual does not work, while the Dispatcher is in a state, it does not call the handler at all
async def cancel(callback_query: types.CallbackQuery):
    ...
dp.register_callback_query_handler(cancel)

Secondly, I don’t know how then to get the state in order to call the finish () method on it.
I would be very grateful for any help!

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