shipany.bot.actions.state_action
shipany.bot.actions.state_action package
Submodules
shipany.bot.actions.state_action.v1 module
class shipany.bot.actions.state_action.v1.SupportedStateActionTypes
Bases: StrEnum
Supported state action types.
- remove: Remove a state.
- store: Store a state.
- load: Load a state.
remove = ‘remove’
store = ‘store’
load = ‘load’
__new__(value)
pydantic model shipany.bot.actions.state_action.v1.StateAction
Bases: BaseModel
Action to store or retrieve a state with respect to the scope.
Payload samples
- Set new variable in chat scope
{"name": "StateAction@1","type": "store","key": "admin","value": "John Doe","scope": ["chat"],}
- Remove variable from chat scope:
{"name": "StateAction@1","type": "remove","key": "admin","scope": ["chat"],}
- Set new variable in user state:
{"name": "StateAction@1","type": "store","key": "","value": "Echo bot","scope": ["user"]}
- Set new variable in user state with expiration time:
{"name": "StateAction@1","type": "store","key": "mute","value": "1","ttl": 3600,"scope": ["user"]}
- Load variable from chat scope to current session:
{"name": "StateAction@1","type": "load","key": "admin","scope": ["chat"]}
Pydantic model parameters
- Config:
- extra: str = ignore
- frozen: bool = True
- Fields:
- Validators:
validate_value»all fields
field name : t.Literal[‘StateAction@1’] [Required]
Action name.
- Validated by:
field action_type : SupportedStateActionTypes [Required] (alias ‘type’)
Action type.
- Validated by:
field key : str [Required]
Name of state to store or retrieve.
- Validated by:
field value : str | None = None
Value to store. It can’t be None if action_type is store. It may contain Jinja2 template using {{ notation }}.
- Validated by:
field scope : list[Scope] = []
Scope of state action. Default is empty list which means global scope available for all.
- Validated by:
field ttl : int | None = None
Time to live in seconds. Default is None which means no expiration.
- Validated by:
validator validate_value » all fields
Validate model.
If action type is store, value cannot be None.
- Parameters: self (Self)
- Return type: Self