telega/flow/registry
FlowRegistry and router integration.
Types
Flow registry for centralized flow management
pub opaque type FlowRegistry(session, error)
Values
pub fn apply_to_router(
router: router.Router(session, error),
registry: FlowRegistry(session, error),
) -> router.Router(session, error)
Apply all registered flows to a router
pub fn call_flow(
ctx ctx: bot.Context(session, error),
registry registry: FlowRegistry(session, error),
name flow_name: String,
initial initial_data: dict.Dict(String, String),
) -> Result(bot.Context(session, error), error)
Call a registered flow from any handler
pub fn cancel_flow_instance(
registry: FlowRegistry(session, error),
flow_id flow_id: String,
) -> Result(Bool, error)
Cancel a specific flow instance by ID
pub fn cancel_user_flows(
registry: FlowRegistry(session, error),
user_id user_id: Int,
chat_id chat_id: Int,
) -> Result(List(String), error)
Cancel all flows for a user in a chat
pub fn new_registry() -> FlowRegistry(session, error)
Create a new empty flow registry
pub fn register(
registry: FlowRegistry(session, error),
trigger: types.FlowTrigger,
flow: types.Flow(step_type, session, error),
) -> FlowRegistry(session, error)
Add a flow to the registry with a trigger
pub fn register_callable(
registry: FlowRegistry(session, error),
flow: types.Flow(step_type, session, error),
) -> FlowRegistry(session, error)
Register a flow without a trigger (for calling from handlers)
pub fn register_cancel_command(
registry: FlowRegistry(session, error),
command: String,
) -> FlowRegistry(session, error)
Register a cancel command that cancels all active flows for the user
pub fn register_cancel_command_with(
registry: FlowRegistry(session, error),
command: String,
on_cancel: fn(bot.Context(session, error), List(String)) -> Result(
bot.Context(session, error),
error,
),
) -> FlowRegistry(session, error)
Register a cancel command with a custom callback
pub fn register_with_data(
registry: FlowRegistry(session, error),
trigger: types.FlowTrigger,
flow: types.Flow(step_type, session, error),
initial_data: dict.Dict(String, String),
) -> FlowRegistry(session, error)
Add a flow to the registry with a trigger and initial data
pub fn to_handler(
flow flow: types.Flow(step_type, session, error),
) -> fn(bot.Context(session, error), update.Command) -> Result(
bot.Context(session, error),
error,
)
Create a router handler that starts a flow