pub trait HandlerExt<Output> {
// Required methods
fn filter_command<C>(self) -> Self
where C: BotCommands + Send + Sync + 'static;
fn filter_mention_command<C>(self) -> Self
where C: BotCommands + Send + Sync + 'static;
fn enter_dialogue<Upd, S, D>(self) -> Self
where S: Storage<D> + ?Sized + Send + Sync + 'static,
<S as Storage<D>>::Error: Debug + Send,
D: Default + Clone + Send + Sync + 'static,
Upd: GetChatId + Clone + Send + Sync + 'static;
}Expand description
Extension methods for working with dptree handlers.
Required Methods§
Sourcefn filter_command<C>(self) -> Self
fn filter_command<C>(self) -> Self
Returns a handler that accepts a parsed command C.
§Dependency requirements
Sourcefn filter_mention_command<C>(self) -> Self
fn filter_mention_command<C>(self) -> Self
Returns a handler that accepts a parsed command C if the command
contains a bot mention, for example /start@my_bot.
§Dependency requirements
Sourcefn enter_dialogue<Upd, S, D>(self) -> Self
fn enter_dialogue<Upd, S, D>(self) -> Self
Passes Dialogue<D, S> and D as handler dependencies.
It does so by the following steps:
- If an incoming update has no chat ID (
GetChatId::chat_idreturnsNone), the rest of the chain will not be executed. Otherwise, passesDialogue::new(storage, chat_id)forwards. - If
Dialogue::get_or_defaulton the passed dialogue returnsOk, passes the dialogue state forwards. Otherwise, logs an error and the rest of the chain is not executed.
If TELOXIDE_DIALOGUE_BEHAVIOUR environmental variable exists and is
equal to “default”, this function will not panic if it can’t get the
dialogue (if, for example, the state enum was updated). Setting the
value to “panic” will return the initial behaviour.
§Dependency requirements
Arc<S>Upd
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.