A
A
Almaz Akimov2022-04-18 18:44:13
Python
Almaz Akimov, 2022-04-18 18:44:13

Which decorator worked for @dp.callback_query_handler or @dp.message_handler?

aiogram
How to create an action in a function only if the inline button is clicked

@dp.callback_query_handler(text_startswith="create", state=StorageOrganization.save_db)
@dp.message_handler(text=" Организации", state="*")
async def _view_all_org(message: types.Message, state: FSMContext, session: AsyncSession):
    await state.finish()
    await message.delete()
    get_kb = await get_organizations_markup(session)
    await message.answer(" Организации:", reply_markup=get_orgs_markup)
    await message.answer("➖➖➖➖➖➖➖➖➖➖➖➖", reply_markup=get_kb)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2022-04-18
@GolosB

Make a separate function so that each has its own decorator. The common part can be moved into a third function, without a decorator, and called on its own.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question