raito.plugins.scenes.registry module¶
- class raito.plugins.scenes.registry.SceneRegistry(scene, observer, name, middleware)[source]¶
Bases:
objectRegisters 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, andscene.on_edited_message. Call it with a step’s state to handle that step, useany()for a handler that runs on every step, or useenter()to start the scene. ItsSceneMiddlewareis installed on the observer only when the first handler is added, so an event type without scene handlers is never touched.- Parameters:
scene (SceneManager[Any])
observer (TelegramEventObserver)
name (str)
middleware (SceneMiddleware)
- any(*filters)[source]¶
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
/cancelcommand or a persistent “Cancel” button:@mute.on_message.any(filters.Command("cancel")) async def cancel_anywhere(scene: Scene[MuteData]) -> None: await scene.cancel()
- Parameters:
filters (CallbackType) – filters applied on top of “any step of this scene”
- Returns:
decorator for the handler
- Return type:
Callable[[CallbackType], CallbackType]