Storages

In this module stored base of storage’s for finite-state machine.

class aiogram.dispatcher.storage.BaseStorage[исходный код]
Базовые классы: object

In states-storage you can save current user state and data for all steps

classmethod check_address(*, chat: typing.Union[str, int, NoneType] = None, user: typing.Union[str, int, NoneType] = None) -> (typing.Union[str, int], typing.Union[str, int])[исходный код]

In all methods of storage chat or user is always required. If one of this is not presented, need set the missing value based on the presented.

This method performs the above action.

Параметры:
  • chat
  • user
Результат:

close()[исходный код]

Need override this method and use when application is shutdowns. You can save data or etc.

Результат:
finish(*, chat: typing.Union[str, int, NoneType] = None, user: typing.Union[str, int, NoneType] = None)[исходный код]

Finish conversation for user in chat.

Chat or user is always required. If one of this is not presented, need set the missing value based on the presented

Параметры:
  • chat
  • user
Результат:

get_data(*, chat: typing.Union[str, int, NoneType] = None, user: typing.Union[str, int, NoneType] = None, default: typing.Union[str, NoneType] = None) → typing.Dict[исходный код]

Get state-data for user in chat. Return default if data is not presented in storage.

Chat or user is always required. If one of this is not presented, need set the missing value based on the presented

Параметры:
  • chat
  • user
  • default
Результат:

get_state(*, chat: typing.Union[str, int, NoneType] = None, user: typing.Union[str, int, NoneType] = None, default: typing.Union[str, NoneType] = None) → typing.Union[str, NoneType][исходный код]

Get current state of user in chat. Return value stored in default parameter if record is not found.

Chat or user is always required. If one of this is not presented, need set the missing value based on the presented

Параметры:
  • chat
  • user
  • default
Результат:

reset_data(*, chat: typing.Union[str, int, NoneType] = None, user: typing.Union[str, int, NoneType] = None)[исходный код]

Reset data dor user in chat.

Chat or user is always required. If one of this is not presented, need set the missing value based on the presented

Параметры:
  • chat
  • user
Результат:

reset_state(*, chat: typing.Union[str, int, NoneType] = None, user: typing.Union[str, int, NoneType] = None, with_data: typing.Union[bool, NoneType] = True)[исходный код]

Reset state for user in chat. You can use this method for finish conversations.

Chat or user is always required. If one of this is not presented, need set the missing value based on the presented

Параметры:
  • chat
  • user
  • with_data
Результат:

set_data(*, chat: typing.Union[str, int, NoneType] = None, user: typing.Union[str, int, NoneType] = None, data: typing.Dict = None)[исходный код]

Set data for user in chat

Chat or user is always required. If one of this is not presented, need set the missing value based on the presented

Параметры:
  • chat
  • user
  • data
set_state(*, chat: typing.Union[str, int, NoneType] = None, user: typing.Union[str, int, NoneType] = None, state: typing.Union[~AnyStr, NoneType] = None)[исходный код]

Setup new state for user in chat

Chat or user is always required. If one of this is not presented, need set the missing value based on the presented

Параметры:
  • chat
  • user
  • state
update_data(*, chat: typing.Union[str, int, NoneType] = None, user: typing.Union[str, int, NoneType] = None, data: typing.Dict = None, **kwargs)[исходный код]

Update data for user in chat

You can use data parameter or|and kwargs.

Chat or user is always required. If one of this is not presented, need set the missing value based on the presented

Параметры:
  • data
  • chat
  • user
  • kwargs
Результат:

wait_closed()[исходный код]

You need override this method for all asynchronously storage’s like Redis.

Результат:
class aiogram.dispatcher.storage.DisabledStorage[исходный код]
Базовые классы: aiogram.dispatcher.storage.BaseStorage

Empty storage. Use it if you don’t want to use Finite-State Machine