raito.plugins.scenes.steps module

class raito.plugins.scenes.steps.SceneSteps(states)[source]

Bases: object

The ordered steps of a scene, derived from an aiogram StatesGroup.

Owns everything about the step layout — the order used by scene.next and scene.back, the membership checks that detect a stale scene, and the namespace prefix that tells a scene’s own states apart from anything else in FSM storage.

Parameters:

states (object)

owns(raw_state)[source]

Whether raw_state lives in this scene’s namespace (current or removed).

Parameters:

raw_state (str)

Return type:

bool

is_active(raw_state)[source]

Whether raw_state is a step this scene still declares.

Parameters:

raw_state (str)

Return type:

bool

ensure(state)[source]

Validate that state is a step of this scene.

Parameters:

state (State) – state to check

Raises:

ValueError – if state is not one of the scene’s steps

Return type:

None

step_for(raw_state)[source]

Return the step matching raw_state.

Trusts that raw_state is already an active step of this scene — the StateFilter that matched the handler already established that.

Parameters:

raw_state (str) – state aiogram already resolved for this update

Returns:

the matching step

Return type:

State

after(step)[source]

Return the step following step (the first step, from entry).

Parameters:

step (State | None) – current step, or None at entry

Returns:

next step in declaration order

Raises:

RuntimeError – if step is already the last step

Return type:

State

before(step)[source]

Return the step preceding step.

Parameters:

step (State | None) – current step

Returns:

previous step in declaration order

Raises:

RuntimeError – if there is no earlier step

Return type:

State