Finite state machine

Storage

Coming soon…

Available storage’s

Coming soon…

Memory storage

class aiogram.contrib.fsm_storage.memory.MemoryStorage[source]

Bases: aiogram.dispatcher.storage.BaseStorage

In-memory based states storage.

This type of storage is not recommended for usage in bots, because you will lost all states after restarting.

Redis storage

class aiogram.contrib.fsm_storage.redis.RedisStorage(host='localhost', port=6379, db=None, password=None, ssl=None, loop=None, **kwargs)[source]

Bases: aiogram.dispatcher.storage.BaseStorage

Simple Redis-base storage for FSM.

Usage:

storage = RedisStorage('localhost', 6379, db=5)
dp = Dispatcher(bot, storage=storage)

And need to close Redis connection when shutdown

await dp.storage.close()
await dp.storage.wait_closed()

Mongo storage

class aiogram.contrib.fsm_storage.mongo.MongoStorage(host='localhost', port=27017, db_name='aiogram_fsm', uri=None, username=None, password=None, index=True, **kwargs)[source]

Bases: aiogram.dispatcher.storage.BaseStorage

Mongo-based storage for FSM.

Usage:

storage = MongoStorage(host='localhost', port=27017, db_name='aiogram_fsm')
dp = Dispatcher(bot, storage=storage)

And need to close Mongo client connections when shutdown

await dp.storage.close()
await dp.storage.wait_closed()

Rethink DB storage

class aiogram.contrib.fsm_storage.rethinkdb.RethinkDBStorage(host: str = 'localhost', port: int = 28015, db: str = 'aiogram', table: str = 'aiogram', auth_key: Optional[str] = None, user: Optional[str] = None, password: Optional[str] = None, timeout: int = 20, ssl: Optional[dict] = None, loop: Optional[asyncio.events.AbstractEventLoop] = None)[source]

Bases: aiogram.dispatcher.storage.BaseStorage

RethinkDB-based storage for FSM.

Usage:

storage = RethinkDBStorage(db='aiogram', table='aiogram', user='aiogram', password='aiogram_secret')
dispatcher = Dispatcher(bot, storage=storage)

And need to close connection when shutdown

await storage.close()
await storage.wait_closed()

Making own storage’s

Coming soon…

States

Coming soon…

State utils

Coming soon…

State

Coming soon…

States group

Coming soon…