peyk.fsm.context¶
FSM context and event-to-storage-key compatibility helpers.
Functions
|
Build a platform/bot-aware key from a normalized event. |
|
Return a compatibility |
Classes
Read and mutate state/data for one |
|
|
Select which event identities share one FSM conversation. |
- class peyk.fsm.context.FSMStrategy(*values)[source]¶
Bases:
str,EnumSelect which event identities share one FSM conversation.
- USER_IN_CHAT = 'USER_IN_CHAT'¶
- CHAT = 'CHAT'¶
- GLOBAL_USER = 'GLOBAL_USER'¶
- peyk.fsm.context.build_storage_key(event: object, *, platform: str, bot_id: int | str, strategy: str | FSMStrategy = FSMStrategy.USER_IN_CHAT, destiny: str = 'default') StorageKey[source]¶
Build a platform/bot-aware key from a normalized event.
- peyk.fsm.context.conversation_key(event: object, *, platform: str | None = None, bot_id: int | str | None = None) StorageKey[source]¶
Return a compatibility
StorageKeyfor an event.The old form inferred the platform from
event.rawand had no bot ID. That form is deprecated; dispatcher integrations must pass both values.
- class peyk.fsm.context.FSMContext(storage: BaseStorage, key: StorageKey)[source]¶
- class peyk.fsm.context.FSMContext(event: object, storage: BaseStorage | LegacyStringStorage, *, platform: str | None = None, bot_id: int | str | None = None)
Bases:
objectRead and mutate state/data for one
StorageKey.- classmethod for_event(event: object, storage: BaseStorage, *, platform: str, bot_id: int | str, strategy: str | FSMStrategy = FSMStrategy.USER_IN_CHAT, destiny: str = 'default') FSMContext[source]¶
Create a context for a normalized event using explicit identity data.
- async get_value(key: str, default: object = None) object[source]¶
Return one data value, or
defaultwhen absent.