[][src]Struct tbot::event_loop::EventLoop

pub struct EventLoop<C> { /* fields omitted */ }

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::bot!("BOT_TOKEN").event_loop();

bot.text(|_| 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: &'static str)[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(
    &mut self,
    command: &'static str,
    handler: impl FnMut(&Text<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for a command.

pub fn start(&mut self, handler: impl FnMut(&Text<C>) + Send + Sync + 'static)[src]

Adds a new handler for the /start command.

pub fn settings(
    &mut self,
    handler: impl FnMut(&Text<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for the /settings command.

pub fn help(&mut self, handler: impl FnMut(&Text<C>) + Send + Sync + 'static)[src]

Adds a new handler for the /help command.

pub fn edited_command(
    &mut self,
    command: &'static str,
    handler: impl FnMut(&EditedText<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for an edited command.

pub fn after_update(
    &mut self,
    handler: impl FnMut(&Update<C>) + Send + Sync + 'static
)
[src]

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

pub fn animated_sticker(
    &mut self,
    handler: impl FnMut(&AnimatedSticker<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for animated stickers.

pub fn animation(
    &mut self,
    handler: impl FnMut(&Animation<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for animations.

pub fn audio(&mut self, handler: impl FnMut(&Audio<C>) + Send + Sync + 'static)[src]

Adds a new handler for audio.

pub fn before_update(
    &mut self,
    handler: impl FnMut(&Update<C>) + Send + Sync + 'static
)
[src]

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

pub fn chosen_inline(
    &mut self,
    handler: impl FnMut(&ChosenInline<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for chosen inline results.

pub fn contact(
    &mut self,
    handler: impl FnMut(&Contact<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for contacts.

pub fn connected_website(
    &mut self,
    handler: impl FnMut(&ConnectedWebsite<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for connected websites.

pub fn created_group(
    &mut self,
    handler: impl FnMut(&CreatedGroup<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for created groups.

pub fn data_callback(
    &mut self,
    handler: impl FnMut(&DataCallback<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for data callbacks.

pub fn deleted_chat_photo(
    &mut self,
    handler: impl FnMut(&DeletedChatPhoto<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for deleted chat photos.

pub fn document(
    &mut self,
    handler: impl FnMut(&Document<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for documents.

pub fn edited_animation(
    &mut self,
    handler: impl FnMut(&EditedAnimation<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for edited animations.

pub fn edited_audio(
    &mut self,
    handler: impl FnMut(&EditedAudio<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for edited audio.

pub fn edited_document(
    &mut self,
    handler: impl FnMut(&EditedDocument<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for edited documents.

pub fn edited_location(
    &mut self,
    handler: impl FnMut(&EditedLocation<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for edited locations.

pub fn edited_photo(
    &mut self,
    handler: impl FnMut(&EditedPhoto<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for edited photos.

pub fn edited_text(
    &mut self,
    handler: impl FnMut(&EditedText<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for edited text messages.

pub fn edited_video(
    &mut self,
    handler: impl FnMut(&EditedVideo<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for edited videos.

pub fn game_callback(
    &mut self,
    handler: impl FnMut(&GameCallback<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for game callbacks.

pub fn game(&mut self, handler: impl FnMut(&Game<C>) + Send + Sync + 'static)[src]

Adds a new handler for game messages.

pub fn inline(
    &mut self,
    handler: impl FnMut(&Inline<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for inline queries.

pub fn invoice(
    &mut self,
    handler: impl FnMut(&Invoice<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for invoices.

pub fn left_member(
    &mut self,
    handler: impl FnMut(&LeftMember<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for left members.

pub fn location(
    &mut self,
    handler: impl FnMut(&Location<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for locations.

pub fn migration(
    &mut self,
    handler: impl FnMut(&Migration<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for migrations.

pub fn new_chat_photo(
    &mut self,
    handler: impl FnMut(&NewChatPhoto<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for new chat photos.

pub fn new_chat_title(
    &mut self,
    handler: impl FnMut(&NewChatTitle<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for new chat titles.

pub fn new_members(
    &mut self,
    handler: impl FnMut(&NewMembers<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for new members.

pub fn passport(
    &mut self,
    handler: impl FnMut(&Passport<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for passport data.

pub fn payment(
    &mut self,
    handler: impl FnMut(&Payment<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for successful payments.

pub fn photo(&mut self, handler: impl FnMut(&Photo<C>) + Send + Sync + 'static)[src]

Adds a new handler for photos.

pub fn pinned_message(
    &mut self,
    handler: impl FnMut(&PinnedMessage<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for pinned messages.

pub fn poll(&mut self, handler: impl FnMut(&Poll<C>) + Send + Sync + 'static)[src]

Adds a new handler for poll messages.

pub fn pre_checkout(
    &mut self,
    handler: impl FnMut(&PreCheckout<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for pre-checkout queries.

pub fn shipping(
    &mut self,
    handler: impl FnMut(&Shipping<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for shipping queries.

pub fn sticker(
    &mut self,
    handler: impl FnMut(&Sticker<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for stickers.

pub fn text(&mut self, handler: impl FnMut(&Text<C>) + Send + Sync + 'static)[src]

Adds a new handler for text messages.

pub fn unhandled(
    &mut self,
    handler: impl FnMut(&Unhandled<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for unhandled updates.

pub fn updated_poll(
    &mut self,
    handler: impl FnMut(&UpdatedPoll<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for new states of polls.

pub fn venue(&mut self, handler: impl FnMut(&Venue<C>) + Send + Sync + 'static)[src]

Adds a new handler for venues.

pub fn video(&mut self, handler: impl FnMut(&Video<C>) + Send + Sync + 'static)[src]

Adds a new handler for videos.

pub fn video_note(
    &mut self,
    handler: impl FnMut(&VideoNote<C>) + Send + Sync + 'static
)
[src]

Adds a new handler for video notes.

pub fn voice(&mut self, handler: impl FnMut(&Voice<C>) + Send + Sync + 'static)[src]

Adds a new handler for voice messages.

impl<C> EventLoop<C> where
    C: Connect + Sync + 'static,
    C::Transport: 'static,
    C::Future: 'static, 
[src]

pub fn fetch_username(&mut self)[src]

Fetches the bot's username.

Panics

This method panics if there was an error during calling the getMe method.

Auto Trait Implementations

impl<C> Unpin for EventLoop<C>

impl<C> Sync for EventLoop<C> where
    C: Send + Sync

impl<C> Send for EventLoop<C> where
    C: Send + Sync

impl<C> !UnwindSafe for EventLoop<C>

impl<C> !RefUnwindSafe for EventLoop<C>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,