Annotation Interface BotChatState
Restricts a handler method or an entire
@BotController class to specific chat states.
When applied to a method, only that handler is guarded by the declared
states. When applied to a class, the annotation acts as a class-wide default:
every handler method in that class inherits the state requirement, unless the method declares
its own @BotChatState which then overrides the class-level default — identical to the
way Spring MVC's @RequestMapping at class level provides a default path prefix.
An empty value array (the default) means the element accepts any state,
making it a convenient method-level override to "opt out" of a class-level restriction.
// All handlers in this class require "REGISTRATION" state.
@BotController
@BotChatState("REGISTRATION")
public class RegistrationFlow {
@BotText("name")
public String handleName(@BotTextValue String name, ...) { ... } // requires REGISTRATION
@BotText("email")
public String handleEmail(@BotTextValue String email, ...) { ... } // requires REGISTRATION
@BotCommand("/cancel")
@BotChatState // empty value overrides class-level -> matches ANY state
public String cancel() { ... }
}
- Since:
- 0.0.1
- Author:
- Islom Mirsaburov
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
String[] valueThe chat state identifiers that activate this handler.- Returns:
- an array of state name strings; empty array matches any state
- Default:
{}
-