Struct EventLoop

Source
pub struct EventLoop { /* private fields */ }
Expand description

Provides an event loop for handling Telegram updates.

With EventLoop, you can configure handlers and start listening to updates via either polling or webhook.

let mut bot = tbot::from_env!("BOT_TOKEN").event_loop();

bot.text(|_| async { println!("Got a text message") });

bot.polling().start();

tbot has many update handlers, such as text you have seen in the example. You can find all of them below on this page.

Implementations§

Source§

impl EventLoop

Source

pub fn into_stateful<S>(self, state: S) -> StatefulEventLoop<S>
where S: Send + Sync + 'static,

Turns this event loop into a stateful one. Handlers added on this event loop are kept.

Source

pub fn username(&mut self, username: String)

Sets the bot’s username.

The username is used when checking if a command such as /command@username was directed to the bot.

Source

pub fn polling(self) -> Polling

Starts polling configuration.

Source

pub fn webhook(self, url: &str, port: u16) -> Webhook<'_>

Starts webhook configuration.

See our wiki to learn how to use webhook with tbot.

Source

pub fn command<H, F>(&mut self, command: &'static str, handler: H)
where H: Fn(Arc<Command<Text>>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for a command.

Note that commands such as /command@username will be completely ignored unless you configure the event loop with your bot’s username with either username or fetch_username.

Source

pub fn command_if<H, HF, P, PF>( &mut self, command: &'static str, predicate: P, handler: H, )
where H: Fn(Arc<Command<Text>>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Command<Text>>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for a command which is run if the predicate returns true.

Note that commands such as /command@username will be completely ignored unless you configure the event loop with your bot’s username with either username or fetch_username.

Source

pub fn commands<Cm, H, F>(&mut self, commands: Cm, handler: H)
where Cm: IntoIterator<Item = &'static str>, F: Future<Output = ()> + Send + 'static, H: Fn(Arc<Command<Text>>) -> F + Send + Sync + 'static,

Adds a new handler for a sequence of commands.

Note that commands such as /command@username will be completely ignored unless you configure the event loop with your bot’s username with either username or fetch_username.

Source

pub fn commands_if<Cm, H, HF, P, PF>( &mut self, commands: Cm, predicate: P, handler: H, )
where Cm: IntoIterator<Item = &'static str>, H: Fn(Arc<Command<Text>>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Command<Text>>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for a sequence of commands which is run if the predicate returns true.

Note that commands such as /command@username will be completely ignored unless you configure the event loop with your bot’s username with either username or fetch_username.

Source

pub fn start<H, F>(&mut self, handler: H)
where H: Fn(Arc<Command<Text>>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for the /start command.

Source

pub fn start_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Command<Text>>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Command<Text>>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for the /start command which is run if the predicate returns true.

Source

pub fn settings<H, F>(&mut self, handler: H)
where H: Fn(Arc<Command<Text>>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for the /settings command.

Source

pub fn settings_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Command<Text>>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Command<Text>>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for the /settings command which is run if the predicate returns true.

Source

pub fn help<H, F>(&mut self, handler: H)
where H: Fn(Arc<Command<Text>>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for the /help command.

Source

pub fn help_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Command<Text>>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Command<Text>>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for the /help command which is run if the predicate returns true.

Source

pub fn edited_command<H, F>(&mut self, command: &'static str, handler: H)
where H: Fn(Arc<Command<EditedText>>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for an edited command.

Source

pub fn edited_command_if<H, HF, P, PF>( &mut self, command: &'static str, predicate: P, handler: H, )
where H: Fn(Arc<Command<EditedText>>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Command<EditedText>>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for an edited command which is run if the predicate returns true.

Source

pub fn edited_commands<Cm, H, F>(&mut self, commands: Cm, handler: H)
where Cm: IntoIterator<Item = &'static str>, F: Future<Output = ()> + Send + 'static, H: Fn(Arc<Command<EditedText>>) -> F + Send + Sync + 'static,

Adds a new handler for an edited command from sequence of commands.

Source

pub fn edited_commands_if<Cm, H, HF, P, PF>( &mut self, commands: Cm, predicate: P, handler: H, )
where Cm: IntoIterator<Item = &'static str>, H: Fn(Arc<Command<EditedText>>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Command<EditedText>>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for a sequence of edited commands which is run if the predicate returns true.

Source

pub fn after_update<H, F>(&mut self, handler: H)
where H: Fn(Arc<Update>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler which is run after handling an update.

Source

pub fn after_update_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Update>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Update>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler which is run after handling an update and if the predicate returns true.

Source

pub fn animation<H, F>(&mut self, handler: H)
where H: Fn(Arc<Animation>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for animations.

Source

pub fn animation_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Animation>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Animation>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for animations which is run if the predicate returns true.

Source

pub fn audio<H, F>(&mut self, handler: H)
where H: Fn(Arc<Audio>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for audio.

Source

pub fn audio_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Audio>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Audio>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for audio which is run if the predicate returns true.

Source

pub fn before_update<H, F>(&mut self, handler: H)
where H: Fn(Arc<Update>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler which is run before handling an update.

Source

pub fn before_update_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Update>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Update>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler which is run before handling an update and if the predicate returns true.

Source

pub fn chosen_inline<H, F>(&mut self, handler: H)
where H: Fn(Arc<ChosenInline>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for chosen inline results.

Source

pub fn chosen_inline_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<ChosenInline>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<ChosenInline>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for chosen inline results which is run if the predicate returns true.

Source

pub fn contact<H, F>(&mut self, handler: H)
where H: Fn(Arc<Contact>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for contacts.

Source

pub fn contact_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Contact>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Contact>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for contacts which is run if the predicate returns true.

Source

pub fn connected_website<H, F>(&mut self, handler: H)
where H: Fn(Arc<ConnectedWebsite>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for connected websites.

Source

pub fn connected_website_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<ConnectedWebsite>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<ConnectedWebsite>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for connected websites which is run if the predicate returns true.

Source

pub fn created_group<H, F>(&mut self, handler: H)
where H: Fn(Arc<CreatedGroup>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for created groups.

Source

pub fn created_group_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<CreatedGroup>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<CreatedGroup>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for created groups which is run if the predicate returns true.

Source

pub fn data_callback<H, F>(&mut self, handler: H)
where H: Fn(Arc<DataCallback>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for data callbacks.

Source

pub fn data_callback_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<DataCallback>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<DataCallback>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for data callbacks which is run if the predicate returns true.

Source

pub fn deleted_chat_photo<H, F>(&mut self, handler: H)
where H: Fn(Arc<DeletedChatPhoto>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for deleted chat photos.

Source

pub fn deleted_chat_photo_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<DeletedChatPhoto>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<DeletedChatPhoto>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for deleted chat photos which is run if the predicate returns true.

Source

pub fn dice<H, F>(&mut self, handler: H)
where H: Fn(Arc<Dice>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for dice.

Source

pub fn dice_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Dice>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Dice>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for dice which is run if the predicate returns true.

Source

pub fn document<H, F>(&mut self, handler: H)
where H: Fn(Arc<Document>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for documents.

Source

pub fn document_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Document>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Document>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for documents which is run if the predicate returns true.

Source

pub fn edited_animation<H, F>(&mut self, handler: H)
where H: Fn(Arc<EditedAnimation>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for edited animations.

Source

pub fn edited_animation_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<EditedAnimation>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<EditedAnimation>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for edited animations which is run if the predicate returns true.

Source

pub fn edited_audio<H, F>(&mut self, handler: H)
where H: Fn(Arc<EditedAudio>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for edited audio.

Source

pub fn edited_audio_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<EditedAudio>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<EditedAudio>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for edited audio which is run if the predicate returns true.

Source

pub fn edited_document<H, F>(&mut self, handler: H)
where H: Fn(Arc<EditedDocument>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for edited documents.

Source

pub fn edited_document_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<EditedDocument>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<EditedDocument>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for edited documents which is run if the predicate returns true.

Source

pub fn edited_location<H, F>(&mut self, handler: H)
where H: Fn(Arc<EditedLocation>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for edited locations.

Source

pub fn edited_location_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<EditedLocation>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<EditedLocation>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for edited locations which is run if the predicate returns true.

Source

pub fn edited_photo<H, F>(&mut self, handler: H)
where H: Fn(Arc<EditedPhoto>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for edited photos.

Source

pub fn edited_photo_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<EditedPhoto>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<EditedPhoto>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for edited photos which is run if the predicate returns true.

Source

pub fn edited_text<H, F>(&mut self, handler: H)
where H: Fn(Arc<EditedText>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for edited text messages.

Source

pub fn edited_text_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<EditedText>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<EditedText>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for edited text messages which is run if the predicate returns true.

Source

pub fn edited_video<H, F>(&mut self, handler: H)
where H: Fn(Arc<EditedVideo>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for edited videos.

Source

pub fn edited_video_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<EditedVideo>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<EditedVideo>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for edited videos which is run if the predicate returns true.

Source

pub fn game_callback<H, F>(&mut self, handler: H)
where H: Fn(Arc<GameCallback>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for game callbacks.

Source

pub fn game_callback_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<GameCallback>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<GameCallback>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for game callbacks which is run if the predicate returns true.

Source

pub fn game<H, F>(&mut self, handler: H)
where H: Fn(Arc<Game>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for game messages.

Source

pub fn game_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Game>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Game>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for game messages which is run if the predicate returns true.

Source

pub fn inline<H, F>(&mut self, handler: H)
where H: Fn(Arc<Inline>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for inline queries.

Source

pub fn inline_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Inline>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Inline>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for inline queries which is run if the predicate returns true.

Source

pub fn invoice<H, F>(&mut self, handler: H)
where H: Fn(Arc<Invoice>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for invoices.

Source

pub fn invoice_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Invoice>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Invoice>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for invoices which is run if the predicate returns true.

Source

pub fn left_member<H, F>(&mut self, handler: H)
where H: Fn(Arc<LeftMember>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for left members.

Source

pub fn left_member_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<LeftMember>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<LeftMember>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for left members which is run if the predicate returns true.

Source

pub fn location<H, F>(&mut self, handler: H)
where H: Fn(Arc<Location>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for locations.

Source

pub fn location_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Location>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Location>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for locations which is run if the predicate returns true.

Source

pub fn migration<H, F>(&mut self, handler: H)
where H: Fn(Arc<Migration>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for migrations.

Source

pub fn migration_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Migration>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Migration>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for migrations which is run if the predicate returns true.

Source

pub fn new_chat_photo<H, F>(&mut self, handler: H)
where H: Fn(Arc<NewChatPhoto>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for new chat photos.

Source

pub fn new_chat_photo_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<NewChatPhoto>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<NewChatPhoto>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for new chat photos which is run if the predicate returns true.

Source

pub fn new_chat_title<H, F>(&mut self, handler: H)
where H: Fn(Arc<NewChatTitle>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for new chat titles.

Source

pub fn new_chat_title_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<NewChatTitle>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<NewChatTitle>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for new chat titles which is run if the predicate returns true.

Source

pub fn new_members<H, F>(&mut self, handler: H)
where H: Fn(Arc<NewMembers>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for new members.

Source

pub fn new_members_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<NewMembers>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<NewMembers>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for new members which is run if the predicate returns true.

Source

pub fn passport<H, F>(&mut self, handler: H)
where H: Fn(Arc<Passport>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for passport data.

Source

pub fn passport_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Passport>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Passport>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for passport data which is run if the predicate returns true.

Source

pub fn payment<H, F>(&mut self, handler: H)
where H: Fn(Arc<Payment>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for successful payments.

Source

pub fn payment_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Payment>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Payment>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for successful payments which is run if the predicate returns true.

Source

pub fn photo<H, F>(&mut self, handler: H)
where H: Fn(Arc<Photo>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for photos.

Source

pub fn photo_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Photo>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Photo>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for photos which is run if the predicate returns true.

Source

pub fn pinned_message<H, F>(&mut self, handler: H)
where H: Fn(Arc<PinnedMessage>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for pinned messages.

Source

pub fn pinned_message_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<PinnedMessage>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<PinnedMessage>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for pinned messages which is run if the predicate returns true.

Source

pub fn poll<H, F>(&mut self, handler: H)
where H: Fn(Arc<Poll>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for poll messages.

Source

pub fn poll_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Poll>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Poll>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for poll messages which is run if the predicate returns true.1

Source

pub fn pre_checkout<H, F>(&mut self, handler: H)
where H: Fn(Arc<PreCheckout>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for pre-checkout queries.

Source

pub fn pre_checkout_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<PreCheckout>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<PreCheckout>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for pre-checkout queries which is run if the predicate returns true.

Source

pub fn shipping<H, F>(&mut self, handler: H)
where H: Fn(Arc<Shipping>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for shipping queries.

Source

pub fn shipping_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Shipping>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Shipping>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for shipping queries which is run if the predicate returns true.

Source

pub fn sticker<H, F>(&mut self, handler: H)
where H: Fn(Arc<Sticker>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for stickers.

Source

pub fn sticker_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Sticker>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Sticker>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for stickers which is run if the predicate returns true.

Source

pub fn text<H, F>(&mut self, handler: H)
where H: Fn(Arc<Text>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for text messages.

Source

pub fn text_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Text>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Text>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for text messages which is run if the predicate returns true.

Source

pub fn unhandled<H, F>(&mut self, handler: H)
where H: Fn(Arc<Unhandled>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for unhandled updates.

Source

pub fn unhandled_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Unhandled>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Unhandled>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for unhandled updates which is run if the predicate returns true.

Source

pub fn updated_poll<H, F>(&mut self, handler: H)
where H: Fn(Arc<UpdatedPoll>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for new states of polls.

Source

pub fn updated_poll_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<UpdatedPoll>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<UpdatedPoll>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for new states of polls which is run if the predicate returns true.

Source

pub fn poll_answer<H, F>(&mut self, handler: H)
where H: Fn(Arc<PollAnswer>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for new answers in the poll.

Source

pub fn poll_answer_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<PollAnswer>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<PollAnswer>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for new answers in the poll which is run if the predicate returns true.

Source

pub fn venue<H, F>(&mut self, handler: H)
where H: Fn(Arc<Venue>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for venues.

Source

pub fn venue_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Venue>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Venue>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for venues which is run if the predicate returns true.

Source

pub fn video<H, F>(&mut self, handler: H)
where H: Fn(Arc<Video>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for videos.

Source

pub fn video_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Video>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Video>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for videos which is run if the predicate returns true.

Source

pub fn video_note<H, F>(&mut self, handler: H)
where H: Fn(Arc<VideoNote>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for video notes.

Source

pub fn video_note_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<VideoNote>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<VideoNote>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for video notes which is run if the predicate returns true.

Source

pub fn voice<H, F>(&mut self, handler: H)
where H: Fn(Arc<Voice>) -> F + Send + Sync + 'static, F: Future<Output = ()> + Send + 'static,

Adds a new handler for voice messages.

Source

pub fn voice_if<H, HF, P, PF>(&mut self, predicate: P, handler: H)
where H: Fn(Arc<Voice>) -> HF + Send + Sync + 'static, HF: Future<Output = ()> + Send + 'static, P: Fn(Arc<Voice>) -> PF + Send + Sync + 'static, PF: Future<Output = bool> + Send + 'static,

Adds a new handler for voice messages which is run if the predicate returns true.

Source

pub async fn fetch_username(&mut self) -> Result<(), MethodCall>

Fetches the bot’s username.

The username is used when checking if a command such as /command@username was directed to the bot.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more