Answer the question
In order to leave comments, you need to log in
How to pass the filter of the triggered handler to the function?
aigram library. Trying to understand how FSM works. In order not to repeat myself, I decided to create one function that reacts to all state filters.
How can I pass to the function which handler the code reacted to?
@dp.message_handler(Command('test'))
async def go_test(message: types.Message):
await message.answer('Вопрос № 1\n Сколько будет 2 + 2 ?')
await Test.q1.set()
@dp.message_handler(state= Test.q1)
@dp.message_handler(state=Test.q2)
@dp.message_handler(state=Test.q3)
async def answer_q(message: types.Message, state: FSMContext):
answer = message.text
await message.answer('Вы вошли в состояние', [По идеи тут должен быть q1])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question