[−][src]Struct tbot::event_loop::EventLoop
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.
Methods
impl<C> EventLoop<C>
[src]
pub fn username(&mut self, username: String)
[src]
Sets the bot's username.
The username is used when checking if a command such as
/command@username
was directed to the bot.
pub fn polling(self) -> Polling<C>
[src]
Starts polling configuration.
pub fn webhook(self, url: &str, port: u16) -> Webhook<C>
[src]
Starts webhook configuration.
See our wiki to learn how to use webhook with tbot
.
pub fn command<H, F>(&mut self, command: &'static str, handler: H) where
H: Fn(Arc<Command<Text<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Command<Text<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for a command.
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<C>>>) -> F + Send + Sync + 'static,
[src]
Cm: IntoIterator<Item = &'static str>,
F: Future<Output = ()> + Send + 'static,
H: Fn(Arc<Command<Text<C>>>) -> F + Send + Sync + 'static,
Adds a new handler for a sequence of commands.
pub fn start<H, F>(&mut self, handler: H) where
H: Fn(Arc<Command<Text<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Command<Text<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for the /start
command.
pub fn settings<H, F>(&mut self, handler: H) where
H: Fn(Arc<Command<Text<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Command<Text<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for the /settings
command.
pub fn help<H, F>(&mut self, handler: H) where
H: Fn(Arc<Command<Text<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Command<Text<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for the /help
command.
pub fn edited_command<H, F>(&mut self, command: &'static str, handler: H) where
H: Fn(Arc<Command<EditedText<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Command<EditedText<C>>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for an edited command.
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<C>>>) -> F + Send + Sync + 'static,
[src]
Cm: IntoIterator<Item = &'static str>,
F: Future<Output = ()> + Send + 'static,
H: Fn(Arc<Command<EditedText<C>>>) -> F + Send + Sync + 'static,
Adds a new handler for an edited command from sequence of commands.
pub fn after_update<H, F>(&mut self, handler: H) where
H: Fn(Arc<Update<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Update<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler which is run after handling an update.
pub fn animation<H, F>(&mut self, handler: H) where
H: Fn(Arc<Animation<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Animation<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for animations.
pub fn audio<H, F>(&mut self, handler: H) where
H: Fn(Arc<Audio<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Audio<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for audio.
pub fn before_update<H, F>(&mut self, handler: H) where
H: Fn(Arc<Update<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Update<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler which is run before handling an update.
pub fn chosen_inline<H, F>(&mut self, handler: H) where
H: Fn(Arc<ChosenInline<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<ChosenInline<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for chosen inline results.
pub fn contact<H, F>(&mut self, handler: H) where
H: Fn(Arc<Contact<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Contact<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for contacts.
pub fn connected_website<H, F>(&mut self, handler: H) where
H: Fn(Arc<ConnectedWebsite<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<ConnectedWebsite<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for connected websites.
pub fn created_group<H, F>(&mut self, handler: H) where
H: Fn(Arc<CreatedGroup<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<CreatedGroup<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for created groups.
pub fn data_callback<H, F>(&mut self, handler: H) where
H: Fn(Arc<DataCallback<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<DataCallback<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for data callbacks.
pub fn deleted_chat_photo<H, F>(&mut self, handler: H) where
H: Fn(Arc<DeletedChatPhoto<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<DeletedChatPhoto<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for deleted chat photos.
pub fn document<H, F>(&mut self, handler: H) where
H: Fn(Arc<Document<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Document<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for documents.
pub fn edited_animation<H, F>(&mut self, handler: H) where
H: Fn(Arc<EditedAnimation<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<EditedAnimation<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for edited animations.
pub fn edited_audio<H, F>(&mut self, handler: H) where
H: Fn(Arc<EditedAudio<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<EditedAudio<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for edited audio.
pub fn edited_document<H, F>(&mut self, handler: H) where
H: Fn(Arc<EditedDocument<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<EditedDocument<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for edited documents.
pub fn edited_location<H, F>(&mut self, handler: H) where
H: Fn(Arc<EditedLocation<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<EditedLocation<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for edited locations.
pub fn edited_photo<H, F>(&mut self, handler: H) where
H: Fn(Arc<EditedPhoto<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<EditedPhoto<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for edited photos.
pub fn edited_text<H, F>(&mut self, handler: H) where
H: Fn(Arc<EditedText<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<EditedText<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for edited text messages.
pub fn edited_video<H, F>(&mut self, handler: H) where
H: Fn(Arc<EditedVideo<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<EditedVideo<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for edited videos.
pub fn game_callback<H, F>(&mut self, handler: H) where
H: Fn(Arc<GameCallback<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<GameCallback<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for game callbacks.
pub fn game<H, F>(&mut self, handler: H) where
H: Fn(Arc<Game<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Game<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for game messages.
pub fn inline<H, F>(&mut self, handler: H) where
H: Fn(Arc<Inline<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Inline<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for inline queries.
pub fn invoice<H, F>(&mut self, handler: H) where
H: Fn(Arc<Invoice<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Invoice<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for invoices.
pub fn left_member<H, F>(&mut self, handler: H) where
H: Fn(Arc<LeftMember<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<LeftMember<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for left members.
pub fn location<H, F>(&mut self, handler: H) where
H: Fn(Arc<Location<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Location<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for locations.
pub fn migration<H, F>(&mut self, handler: H) where
H: Fn(Arc<Migration<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Migration<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for migrations.
pub fn new_chat_photo<H, F>(&mut self, handler: H) where
H: Fn(Arc<NewChatPhoto<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<NewChatPhoto<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for new chat photos.
pub fn new_chat_title<H, F>(&mut self, handler: H) where
H: Fn(Arc<NewChatTitle<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<NewChatTitle<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for new chat titles.
pub fn new_members<H, F>(&mut self, handler: H) where
H: Fn(Arc<NewMembers<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<NewMembers<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for new members.
pub fn passport<H, F>(&mut self, handler: H) where
H: Fn(Arc<Passport<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Passport<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for passport data.
pub fn payment<H, F>(&mut self, handler: H) where
H: Fn(Arc<Payment<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Payment<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for successful payments.
pub fn photo<H, F>(&mut self, handler: H) where
H: Fn(Arc<Photo<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Photo<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for photos.
pub fn pinned_message<H, F>(&mut self, handler: H) where
H: Fn(Arc<PinnedMessage<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<PinnedMessage<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for pinned messages.
pub fn poll<H, F>(&mut self, handler: H) where
H: Fn(Arc<Poll<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Poll<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for poll messages.
pub fn pre_checkout<H, F>(&mut self, handler: H) where
H: Fn(Arc<PreCheckout<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<PreCheckout<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for pre-checkout queries.
pub fn shipping<H, F>(&mut self, handler: H) where
H: Fn(Arc<Shipping<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Shipping<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for shipping queries.
pub fn sticker<H, F>(&mut self, handler: H) where
H: Fn(Arc<Sticker<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Sticker<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for stickers.
pub fn text<H, F>(&mut self, handler: H) where
H: Fn(Arc<Text<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Text<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for text messages.
pub fn unhandled<H, F>(&mut self, handler: H) where
H: Fn(Arc<Unhandled<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Unhandled<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for unhandled updates.
pub fn updated_poll<H, F>(&mut self, handler: H) where
H: Fn(Arc<UpdatedPoll<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<UpdatedPoll<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for new states of polls.
pub fn poll_answer<H, F>(&mut self, handler: H) where
H: Fn(Arc<PollAnswer<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<PollAnswer<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for new answers in the poll.
pub fn venue<H, F>(&mut self, handler: H) where
H: Fn(Arc<Venue<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Venue<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for venues.
pub fn video<H, F>(&mut self, handler: H) where
H: Fn(Arc<Video<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Video<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for videos.
pub fn video_note<H, F>(&mut self, handler: H) where
H: Fn(Arc<VideoNote<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<VideoNote<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for video notes.
pub fn voice<H, F>(&mut self, handler: H) where
H: Fn(Arc<Voice<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
[src]
H: Fn(Arc<Voice<C>>) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a new handler for voice messages.
impl<C: Connector> EventLoop<C>
[src]
pub async fn fetch_username<'_>(&'_ mut self) -> Result<(), MethodCall>
[src]
Fetches the bot's username.
Auto Trait Implementations
impl<C> !RefUnwindSafe for EventLoop<C>
impl<C> Send for EventLoop<C> where
C: Send + Sync,
C: Send + Sync,
impl<C> Sync for EventLoop<C> where
C: Send + Sync,
C: Send + Sync,
impl<C> Unpin for EventLoop<C>
impl<C> !UnwindSafe for EventLoop<C>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,