Есть состояния:
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)
Где states -
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 -
state = bot_dispatcher.current_state(user=usr_msg.from_user.id)
Проблема в том, что после того как отработала строка
await state.set_state(FSM_states.start_chat_state)
- не вызывается ранее привязанный в цикле метод.
даже, если в лоб написать вот так:
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')
- метод не вызывается