Struct tbot::state::StatefulEventLoop[][src]

#[must_use]pub struct StatefulEventLoop<S> { /* fields omitted */ }

A stateful event loop.

Implementations

impl<S> StatefulEventLoop<S>[src]

#[must_use]pub fn get_state(&self) -> Arc<S>[src]

Returns an Arc to the state.

pub fn into_stateless(self) -> EventLoop[src]

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

pub fn with_other_state<T>(self, other_state: T) -> StatefulEventLoop<T> where
    T: Send + Sync + 'static, 
[src]

Turns this event loop into another with other state. Handlers added on this event loop are still kept and will receive the previous state.

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 async fn fetch_username(&mut self) -> Result<(), MethodCall>[src]

Fetches 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<S>[src]

Starts polling configuration.

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

Starts webhook configuration.

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

impl<S> StatefulEventLoop<S> where
    S: Send + Sync + 'static, 
[src]

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

Registers 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.

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

Registers a new handler for a command and sets its description.

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.

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

Registers 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.

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

Registers a new handler for the /start command.

pub fn start_with_description<H, F>(
    &mut self,
    description: &'static str,
    handler: H
) where
    H: Fn(Arc<Command>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for the /start command and sets its description.

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

Registers a new handler for the /help command.

pub fn help_with_description<H, F>(
    &mut self,
    description: &'static str,
    handler: H
) where
    H: Fn(Arc<Command>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for the /help command and sets its description.

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

Registers a new handler for the /settings command.

pub fn settings_with_description<H, F>(
    &mut self,
    description: &'static str,
    handler: H
) where
    H: Fn(Arc<Command>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for the /settings command and sets its description.

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

Registers 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>,
    H: Fn(Arc<EditedCommand>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for a sequence of edited commands.

pub fn any_update<H, F>(&mut self, handler: H) where
    H: Fn(Arc<AnyUpdate>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for all incoming updates.

any_update handlers are spawned before specialized handlers, for every update that could be deserialized (this means that processing new updates on old versions of tbot is not possible even via any_update).

Note “spawned”: every handler is executed using [tokio::spawn], and tbot won’t wait for them to finish. As such, any_update is not suitable for running some code before every specialized handler.

Also, any_update does not affect unhandled in any way. It’s executed if a specialized handler corresponding to the incoming update wasn’t registered.

Registering specialized handler is still preferred. if at least one any_update handler is registered, tbot will have to clone every update in order to execute these and specialized handlers.

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

Registers a new handler for animations.

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

Registers a new handler for audio.

pub fn changed_auto_delete_timer<H, F>(&mut self, handler: H) where
    H: Fn(Arc<ChangedAutoDeleteTimer>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for changed auto-delete timers.

pub fn chat_member<H, F>(&mut self, handler: H) where
    H: Fn(Arc<ChatMember>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for chat members’ updated information.

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

Registers a new handler for chosen inline results.

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

Registers a new handler for contacts.

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

Registers a new handler for connected websites.

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

Registers a new handler for created groups.

pub fn message_data_callback<H, F>(&mut self, handler: H) where
    H: Fn(Arc<MessageDataCallback>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for data callbacks from chat messages.

pub fn inline_data_callback<H, F>(&mut self, handler: H) where
    H: Fn(Arc<InlineDataCallback>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for data callbacks from inline messages.

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

Registers a new handler for deleted chat photos.

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

Registers a new handler for dice.

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

Registers a new handler for documents.

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

Registers a new handler for edited animations.

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

Registers a new handler for edited audio.

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

Registers a new handler for edited documents.

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

Registers a new handler for edited locations.

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

Registers a new handler for edited photos.

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

Registers a new handler for edited text messages.

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

Registers a new handler for edited videos.

pub fn ended_voice_chat<H, F>(&mut self, handler: H) where
    H: Fn(Arc<EndedVoiceChat>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for when a voice chat is ended.

pub fn message_game_callback<H, F>(&mut self, handler: H) where
    H: Fn(Arc<MessageGameCallback>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for game callbacks from chat messages.

pub fn inline_game_callback<H, F>(&mut self, handler: H) where
    H: Fn(Arc<InlineGameCallback>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for game callbacks from inline messages.

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

Registers a new handler for game messages.

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

Registers a new handler for inline queries.

pub fn invited_voice_chat_participants<H, F>(&mut self, handler: H) where
    H: Fn(Arc<InvitedVoiceChatParticipants>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for when users are invited to a voice chat.

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

Registers a new handler for invoices.

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

Registers a new handler for left members.

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

Registers a new handler for locations.

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

Registers a new handler for migrations.

pub fn my_chat_member<H, F>(&mut self, handler: H) where
    H: Fn(Arc<MyChatMember>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for the bot’s update chat member status.

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

Registers a new handler for new chat photos.

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

Registers a new handler for new chat titles.

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

Registers a new handler for new members.

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

Registers a new handler for passport data.

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

Registers a new handler for successful payments.

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

Registers a new handler for photos.

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

Registers a new handler for pinned messages.

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

Registers a new handler for poll messages.

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

Registers a new handler for pre-checkout queries.

pub fn proximity_alert<H, F>(&mut self, handler: H) where
    H: Fn(Arc<ProximityAlert>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for proximity alerts.

pub fn scheduled_voice_chat<H, F>(&mut self, handler: H) where
    H: Fn(Arc<ScheduledVoiceChat>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for when a voice chat is scheduled.

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

Registers a new handler for shipping queries.

pub fn started_voice_chat<H, F>(&mut self, handler: H) where
    H: Fn(Arc<StartedVoiceChat>, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 
[src]

Registers a new handler for when a voice chat is started.

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

Registers a new handler for stickers.

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

Registers a new handler for text messages.

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

Registers a new handler for unhandled updates.

Note that regisering any_update handlers does not affect unhandled handlers in any way. An unhandled handler is spawned if a specialized handler corresponding to the incoming update was not registered.

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

Registers a new handler for new states of polls.

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

Registers a new handler for new answers in the poll.

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

Registers a new handler for venues.

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

Registers a new handler for videos.

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

Registers a new handler for video notes.

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

Registers a new handler for voice messages.

Auto Trait Implementations

impl<S> !RefUnwindSafe for StatefulEventLoop<S>

impl<S> Send for StatefulEventLoop<S> where
    S: Send + Sync

impl<S> Sync for StatefulEventLoop<S> where
    S: Send + Sync

impl<S> Unpin for StatefulEventLoop<S>

impl<S> !UnwindSafe for StatefulEventLoop<S>

Blanket Implementations

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

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

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

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

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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> WithSubscriber for T[src]