Answer the question
In order to leave comments, you need to log in
Aiogram FSM not changing state?
There are states:
class FSM_states(StatesGroup):
start_chat_state=State()
leave_chat_state=State()
see_event_state=State()
wait_chat_msg_state=State()
resend_to_owner_state=State()
async def start_chat_handler(message: types.Message,state: FSMContext):
pass
async def leave_chat_handler(message: types.Message, state: FSMContext):
pass
async def see_event_handler(message: types.Message, state: FSMContext):
#some code
async def wait_chat_msg_handler(message: types.Message, state: FSMContext):
pass
async def resend_to_owner_handler(message: types.Message, state: FSMContext):
pass
async def start_fsm(dsip:Dispatcher,states:dict,state):
for s in states:
dsip.register_message_handler(states[s],state=s)
await state.set_state(FSM_states.start_chat_state)
fsm_states_dist={
FSM_handlers.FSM_states.leave_chat_state: FSM_handlers.leave_chat_handler,
FSM_handlers.FSM_states.start_chat_state:FSM_handlers.see_event_handler,
FSM_handlers.FSM_states.wait_chat_msg_state:FSM_handlers.wait_chat_msg_handler,
FSM_handlers.FSM_states.start_chat_state:FSM_handlers.start_chat_handler}
state = bot_dispatcher.current_state(user=usr_msg.from_user.id)
await state.set_state(FSM_states.start_chat_state)
- the method previously bound in the loop is not called. import aiogram.types as types
from aiogram.dispatcher import FSMContext
FSM_handlers.FSM_states.start_chat_state.set()
@bot_dispatcher.message_handler(state=FSM_handlers.FSM_states.start_chat_state)
async def test_m(message: types.Message, state: FSMContext):
print('d')
- the method is not called
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