raito.core.routers.router module

class raito.core.routers.router.Router(*, name=None, priority=0, autoload=True)[исходный код]

Базовые классы: Router

An expanded aiogram router implementation.

Параметры:
  • name (str | None)

  • priority (int)

  • autoload (bool)

on_pagination(name, *filters)[исходный код]

Register pagination handler for specific name.

Параметры:
  • name (str) – pagination name

  • filters (CallbackType)

Результат:

decorator function

Тип результата:

CallbackType

scene(states: type[StatesGroup]) SceneManager[SceneData][исходный код]
scene(states: type[StatesGroup], *, data: type[TSceneData]) SceneManager[TSceneData]

Create a per-update dialog flow over an aiogram StatesGroup.

Every entry and step is registered as a regular message handler, so middleware dependencies — including database sessions — stay scoped to a single update and are released between steps.

Параметры:
  • states (type[StatesGroup]) – StatesGroup whose states are the scene’s steps, in order

  • data (type[SceneData]) – SceneData subclass used for the typed draft

Результат:

the scene, to attach handlers with .enter and .on

Исключение:

ValueError – if the router already owns a scene for these states

Тип результата:

SceneManager[Any]

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

Called when the signature of an entered command is incorrect.

Пример

@router.on_command_signature_error()
async def handler(event, command, params, description) -> None:
    await event.reply(get_command_help(command, params, description))
Параметры:
  • event (Message) – Message event

  • handler (HandlerObject) – Handler object

  • command (CommandObject) – Command object

  • params (dict[str, int | str | bool | float]) – Command parameters

  • description (str | None) – Optional command description

Тип результата:

CallbackType

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

Register a lifespan function for a given router, similar to FastAPI’s lifespan handler. The function must be an async generator: it runs setup before yield, and cleanup after.

Тип результата:

Callable[[Callable[[…], AsyncGenerator[None, None]]], Callable[[…], AsyncGenerator[None, None]]]