Trait teloxide::dispatching::HandlerExt
source · pub trait HandlerExt<Output> {
fn filter_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 + 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) -> Selfwhere
C: BotCommands + Send + Sync + 'static,
fn filter_command<C>(self) -> Selfwhere
C: BotCommands + Send + Sync + 'static,
Returns a handler that accepts a parsed command C
.
Dependency requirements
sourcefn enter_dialogue<Upd, S, D>(self) -> Selfwhere
S: Storage<D> + ?Sized + Send + Sync + 'static,
<S as Storage<D>>::Error: Debug + Send,
D: Default + Send + Sync + 'static,
Upd: GetChatId + Clone + Send + Sync + 'static,
fn enter_dialogue<Upd, S, D>(self) -> Selfwhere
S: Storage<D> + ?Sized + Send + Sync + 'static,
<S as Storage<D>>::Error: Debug + Send,
D: Default + Send + Sync + 'static,
Upd: GetChatId + Clone + Send + Sync + 'static,
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_id
returnsNone
), the rest of the chain will not be executed. Otherwise, passesDialogue::new(storage, chat_id)
forwards. - If
Dialogue::get_or_default
on the passed dialogue returnsOk
, passes the dialogue state forwards. Otherwise, logs an error and the rest of the chain is not executed.
Dependency requirements
Arc<S>
Upd