from transitions import Machine from event_handler_connector import ehc class FSMBase: states, transitions = [], [] def __init__(self, initial: str = None): self.machine = Machine(model=self, states=self.states, transitions=self.transitions, initial=initial or self.states[0], send_event=True, ignore_invalid_triggers=True, after_state_change='forward_message') def forward_message(self, event_data): message = event_data.kwargs.get('message') ehc.send_message(message)