Struct teloxide::dispatching::Dispatcher
source · pub struct Dispatcher<R, Err, Key> { /* private fields */ }
Expand description
The base for update dispatching.
Updates from different chats are handled concurrently, whereas updates from
the same chats are handled sequentially. If the dispatcher is unable to
determine a chat ID of an incoming update, it will be handled concurrently.
Note that this behaviour can be altered with distribution_function
.
See also: “Dispatching or REPLs?”
Implementations§
source§impl<R, Err> Dispatcher<R, Err, DefaultKey>where
R: Requester + Clone + Send + Sync + 'static,
Err: Send + Sync + 'static,
impl<R, Err> Dispatcher<R, Err, DefaultKey>where
R: Requester + Clone + Send + Sync + 'static,
Err: Send + Sync + 'static,
sourcepub fn builder(
bot: R,
handler: UpdateHandler<Err>
) -> DispatcherBuilder<R, Err, DefaultKey>where
Err: Debug,
pub fn builder(
bot: R,
handler: UpdateHandler<Err>
) -> DispatcherBuilder<R, Err, DefaultKey>where
Err: Debug,
Constructs a new DispatcherBuilder
with bot
and handler
.
source§impl<R, Err, Key> Dispatcher<R, Err, Key>where
R: Requester + Clone + Send + Sync + 'static,
Err: Send + Sync + 'static,
Key: Hash + Eq + Clone,
impl<R, Err, Key> Dispatcher<R, Err, Key>where
R: Requester + Clone + Send + Sync + 'static,
Err: Send + Sync + 'static,
Key: Hash + Eq + Clone,
sourcepub async fn dispatch(&mut self)where
R: Requester + Clone,
<R as Requester>::GetUpdates: Send,
pub async fn dispatch(&mut self)where
R: Requester + Clone,
<R as Requester>::GetUpdates: Send,
Starts your bot with the default parameters.
The default parameters are a long polling update listener and log all errors produced by this listener.
Each time a handler is invoked, Dispatcher
adds the following
dependencies (in addition to those passed to
DispatcherBuilder::dependencies
):
- Your bot passed to
Dispatcher::builder
; - An update from Telegram;
crate::types::Me
(can be used inHandlerExt::filter_command
).
sourcepub async fn dispatch_with_listener<'a, UListener, Eh>(
&'a mut self,
update_listener: UListener,
update_listener_error_handler: Arc<Eh>
)where
UListener: UpdateListener + 'a,
Eh: ErrorHandler<UListener::Err> + 'a,
UListener::Err: Debug,
pub async fn dispatch_with_listener<'a, UListener, Eh>(
&'a mut self,
update_listener: UListener,
update_listener_error_handler: Arc<Eh>
)where
UListener: UpdateListener + 'a,
Eh: ErrorHandler<UListener::Err> + 'a,
UListener::Err: Debug,
Starts your bot with custom update_listener
and
update_listener_error_handler
.
This method adds the same dependencies as Dispatcher::dispatch
.
sourcepub fn setup_ctrlc_handler(&mut self) -> &mut Self
👎Deprecated since 0.10.0: use enable_ctrlc_handler
on builder insteadAvailable on crate feature ctrlc_handler
only.
pub fn setup_ctrlc_handler(&mut self) -> &mut Self
enable_ctrlc_handler
on builder insteadctrlc_handler
only.Setups the ^C
handler that shutdown
s dispatching.
sourcepub fn shutdown_token(&self) -> ShutdownToken
pub fn shutdown_token(&self) -> ShutdownToken
Returns a shutdown token, which can later be used to shutdown dispatching.