Overview
TheNumericState attribute and keeper provide integer-based state management for chat sessions. States automatically increment and decrement, making them ideal for linear conversation flows like multi-step forms or sequential processes.
NumericStateAttribute
Apply this attribute to handlers to filter by numeric state values.Constructors
Associates the handler with a specific integer state using the default sender ID resolver.Parameters:
myState(int): The specific state value to match
Associates the handler with a special state mode using the default sender ID resolver.Parameters:
specialState(SpecialState): Special state mode (NoState,AnyState)
Associates the handler with a specific state using a custom key resolver.Parameters:
myState(int): The specific state value to matchkeyResolver(IStateKeyResolver<long>): Custom key resolver for state management
Associates the handler with a special state mode using a custom key resolver.Parameters:
specialState(SpecialState): Special state modekeyResolver(IStateKeyResolver<long>): Custom key resolver
Properties
Gets the default state value, which is
1.NumericStateKeeper
Manages numeric state storage and transitions.Methods
Sets the numeric state for the specified update.Parameters:
keySource(Update): The update to use as a key sourcenewState(int): The new state value
Gets the current numeric state for the specified update.Parameters:
keySource(Update): The update to use as a key source
Attempts to get the state for the specified update.Parameters:
keySource(Update): The update to use as a key sourcestate(out int?): The state value if found
true if state exists; otherwise falseChecks whether a state exists for the specified update.Parameters:
keySource(Update): The update to use as a key source
true if state exists; otherwise falseCreates a new state for the specified update using the default value (1).Parameters:
keySource(Update): The update to use as a key source
Deletes the state for the specified update.Parameters:
keySource(Update): The update to use as a key source
Increments the numeric state by 1.Parameters:
keySource(Update): The update to use as a key source
Decrements the numeric state by 1.Parameters:
keySource(Update): The update to use as a key source
Extension Methods
Convenience methods available onIHandlerContainer:
Usage Example
Key Features
- Automatic Transitions: States increment/decrement automatically
- Default State: Starts at 1 by default
- Linear Flows: Perfect for sequential processes
- Simple State Management: Easy to track progress through numbered steps
See Also
- StringState - For named state management
- EnumState - For type-safe state management
- State Keepers - Base state keeper architecture