raito.plugins.scenes.registry module

class raito.plugins.scenes.registry.SceneRegistry(scene, observer, name, middleware)[исходный код]

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

Registers a scene’s handlers for one aiogram event type.

A scene exposes one of these per event as scene.on_message, scene.on_callback_query, and scene.on_edited_message. Call it with a step’s state to handle that step, use any() for a handler that runs on every step, or use enter() to start the scene. Its SceneMiddleware is installed on the observer only when the first handler is added, so an event type without scene handlers is never touched.

Параметры:
any(*filters)[исходный код]

Register a handler that runs on any active step of this scene.

Useful for something that should work no matter where the user is in the dialog, e.g. a /cancel command or a persistent «Cancel» button:

@mute.on_message.any(filters.Command("cancel"))
async def cancel_anywhere(scene: Scene[MuteData]) -> None:
    await scene.cancel()
Параметры:

filters (CallbackType) – filters applied on top of «any step of this scene»

Результат:

decorator for the handler

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

Callable[[CallbackType], CallbackType]

enter(*filters)[исходный код]

Register a handler that starts the scene from a fresh draft.

Параметры:

filters (CallbackType) – filters that trigger the scene, e.g. Command("mute")

Результат:

decorator for the entry handler

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

Callable[[CallbackType], CallbackType]