[][src]Struct tbot::Bot

#[must_use]pub struct Bot { /* fields omitted */ }

Provides methods to call the Bots API.

A Bot lets you call methods from the methods module.

let bot = tbot::from_env!("BOT_TOKEN");
let me = bot.get_me().call().await.unwrap();
dbg!(me);

Besides, a Bot is used to construct an EventLoop — a struct responsible for configuring handlers and listening to updates.

Implementations

impl Bot[src]

pub fn new(token: String) -> Self[src]

Constructs a new Bot.

pub fn with_proxy(token: String, proxy: Proxy) -> Self[src]

Constructs a Bot with the provided proxy.

pub fn from_env_with_proxy(env_var: &'static str, proxy: Proxy) -> Self[src]

Like Bot::from_env, but with a provided proxy.

pub async fn download_file<'_, '_>(
    &'_ self,
    file: &'_ File
) -> Result<Vec<u8>, Download>
[src]

Downloads a file.

pub fn from_env(env_var: &'static str) -> Self[src]

Constructs a new Bot, extracting the token from the environment at runtime.

If you need to extract the token at compile time, use from_env!.

Example

let bot = tbot::Bot::from_env("BOT_TOKEN");
let me = bot.get_me().call().await.unwrap();
dbg!(me);

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

Constructs an EventLoop.

pub fn stateful_event_loop<S>(self, state: S) -> StatefulEventLoop<S> where
    S: Send + Sync + 'static, 
[src]

Constructs a stateful event loop.

pub fn add_sticker_to_set<'a>(
    &'a self,
    user_id: Id,
    name: &'a str,
    png_sticker: impl Into<StickerForStickerSet<'a>>,
    emojis: &'a str
) -> AddStickerToSet<'a>
[src]

Adds a new sticker to an existing sticker set.

pub fn create_new_sticker_set<'a>(
    &'a self,
    user_id: Id,
    name: &'a str,
    title: &'a str,
    png_sticker: impl Into<StickerForStickerSet<'a>>,
    emojis: &'a str
) -> CreateNewStickerSet<'a>
[src]

Creates a new sticker set.

pub fn delete_chat_photo<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>
) -> DeleteChatPhoto<'a>
[src]

Deletes a chat's photo.

pub fn delete_chat_sticker_set<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>
) -> DeleteChatStickerSet<'a>
[src]

Deletes a chat's sticker set.

pub fn delete_message<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id
) -> DeleteMessage<'a>
[src]

Deletes a message from a chat.

pub fn delete_sticker_from_set<'a>(
    &'a self,
    sticker: &'a str
) -> DeleteStickerFromSet<'a>
[src]

Deletes a sticker from a sticker set.

pub fn edit_inline_caption<'a>(
    &'a self,
    inline_message_id: Ref<'a>,
    caption: impl Into<Text<'a>>
) -> EditInlineCaption<'a>
[src]

Edits the caption of a media message sent via the inline mode.

pub fn edit_inline_location<'a>(
    &'a self,
    inline_message_id: Ref<'a>,
    position: (f64, f64)
) -> EditInlineLocation<'a>
[src]

Edits a live location sent via the inline mode.

pub fn edit_inline_media<'a>(
    &'a self,
    inline_message_id: Ref<'a>,
    media: impl Into<EditableMedia<'a>>
) -> EditInlineMedia<'a>
[src]

Edits the media of a message sent via the inline mode.

pub fn edit_inline_reply_markup<'a>(
    &'a self,
    inline_message_id: Ref<'a>,
    reply_markup: Keyboard<'a>
) -> EditInlineReplyMarkup<'a>
[src]

Edits the inline keyboard of a message sent via the inline mode.

pub fn edit_inline_text<'a>(
    &'a self,
    inline_message_id: Ref<'a>,
    text: impl Into<Text<'a>>
) -> EditInlineText<'a>
[src]

Edits the text of a message sent via the inline mode.

pub fn edit_message_caption<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id,
    caption: impl Into<Text<'a>>
) -> EditMessageCaption<'a>
[src]

Edits the caption of a media message sent by the bot itself.

pub fn edit_message_location<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id,
    position: (f64, f64)
) -> EditMessageLocation<'a>
[src]

Edits a live location sent by the bot itself.

pub fn edit_message_media<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id,
    media: impl Into<EditableMedia<'a>>
) -> EditMessageMedia<'a>
[src]

Edits a live location sent by the bot itself.

pub fn edit_message_reply_markup<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id,
    reply_markup: Keyboard<'a>
) -> EditMessageReplyMarkup<'a>
[src]

Edits the inline keyboard of a message sent by the bot itself.

pub fn edit_message_text<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id,
    text: impl Into<Text<'a>>
) -> EditMessageText<'a>
[src]

Edits the text of a message sent by the bot itself.

Exports a chat's invite link.

pub fn forward_message<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    from_chat_id: impl ImplicitChatId<'a>,
    message_id: Id
) -> ForwardMessage<'a>
[src]

Forwards a message.

pub fn get_chat<'a>(&'a self, chat_id: impl ImplicitChatId<'a>) -> GetChat<'a>[src]

Gets information about a chat.

pub fn get_file<'a>(&'a self, file_id: &'a impl AsFileId) -> GetFile<'a>[src]

Gets information about a file.

pub fn get_inline_game_high_scores<'a>(
    &'a self,
    inline_message_id: Ref<'a>,
    user_id: Id
) -> GetInlineGameHighScores<'a>
[src]

Gets an excerpt from the high score table of a game sent via the inline mode.

pub fn get_chat_administrators<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>
) -> GetChatAdministrators<'a>
[src]

Gets information about a chat's admins.

pub fn get_chat_member<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    user_id: Id
) -> GetChatMember<'a>
[src]

Gets information about a chat's member.

pub fn get_chat_members_count<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>
) -> GetChatMembersCount<'a>
[src]

Gets a chat's member count.

pub fn get_message_game_high_scores<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id,
    user_id: Id
) -> GetMessageGameHighScores<'a>
[src]

Gets an excerpt from the high score table of a game sent by the bot itself.

pub fn get_me(&self) -> GetMe<'_>[src]

Gets information about the bot.

pub fn get_my_commands(&self) -> GetMyCommands<'_>[src]

Gets the list of the bot's commands.

pub fn get_sticker_set<'a>(&'a self, name: &'a str) -> GetStickerSet<'a>[src]

Gets a sticker set by its name.

pub fn get_user_profile_photos(&self, user_id: Id) -> GetUserProfilePhotos<'_>[src]

Gets a user's profile photos.

pub fn get_webhook_info(&self) -> GetWebhookInfo<'_>[src]

Gets information about the bot's webhook.

pub fn kick_chat_member<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    user_id: Id
) -> KickChatMember<'a>
[src]

Kicks a member out of a chat.

pub fn leave_chat<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>
) -> LeaveChat<'a>
[src]

Leaves a chat.

pub fn pin_chat_message<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id
) -> PinChatMessage<'a>
[src]

Pins a message in a chat.

pub fn promote_chat_member<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    user_id: Id
) -> PromoteChatMember<'a>
[src]

Promotes a chat member to an admin.

pub fn restrict_chat_member<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    user_id: Id,
    permissions: Permissions
) -> RestrictChatMember<'a>
[src]

Restricts a chat member.

pub fn send_animation<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    animation: Animation<'a>
) -> SendAnimation<'a>
[src]

Sends an animation.

pub fn send_audio<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    audio: Audio<'a>
) -> SendAudio<'a>
[src]

Sends an audio.

pub fn send_chat_action<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    action: Action
) -> SendChatAction<'a>
[src]

Sends a chat action.

pub fn send_contact<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    phone_number: &'a str,
    first_name: &'a str
) -> SendContact<'a>
[src]

Sends a contact.

pub fn send_game<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    game_short_name: &'a str
) -> SendGame<'a>
[src]

Sends a game.

pub fn send_dice<'a>(&'a self, chat_id: impl ImplicitChatId<'a>) -> SendDice<'a>[src]

Sends a dice.

pub fn send_document<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    document: Document<'a>
) -> SendDocument<'a>
[src]

Sends a document.

pub fn send_invoice<'a>(
    &'a self,
    chat_id: impl Into<Id>,
    title: &'a str,
    description: &'a str,
    payload: &'a str,
    provider_token: &'a str,
    start_parameter: &'a str,
    currency: &'a str,
    prices: &'a [LabeledPrice<'a>]
) -> SendInvoice<'a>
[src]

Sends an invoice.

pub fn send_location<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    position: (f64, f64)
) -> SendLocation<'a>
[src]

Sends a location.

pub fn send_media_group<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    media: &'a [GroupMedia<'a>]
) -> SendMediaGroup<'a>
[src]

Sends an album.

pub fn send_message<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    text: impl Into<Text<'a>>
) -> SendMessage<'a>
[src]

Sends a text message.

pub fn send_photo<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    photo: Photo<'a>
) -> SendPhoto<'a>
[src]

Sends a photo.

pub fn send_poll<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    poll: &'a Any<'a>
) -> SendPoll<'a>
[src]

Sends a poll.

pub fn send_sticker<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    sticker: Sticker<'a>
) -> SendSticker<'a>
[src]

Sends a sticker.

pub fn send_venue<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    position: (f64, f64),
    title: &'a str,
    address: &'a str
) -> SendVenue<'a>
[src]

Sends a venue.

pub fn send_video_note<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    video_note: VideoNote<'a>
) -> SendVideoNote<'a>
[src]

Sends a video note.

pub fn send_video<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    video: Video<'a>
) -> SendVideo<'a>
[src]

Sends a video.

pub fn send_voice<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    voice: Voice<'a>
) -> SendVoice<'a>
[src]

Sends a voice.

pub fn set_chat_administrator_custom_title<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    user_id: Id,
    custom_title: &'a str
) -> SetChatAdministratorCustomTitle<'a>
[src]

Sets a custom title for an admin in a chat.

pub fn set_chat_description<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    description: &'a str
) -> SetChatDescription<'a>
[src]

Sets a chat's description.

pub fn set_chat_permissions<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    permissions: Permissions
) -> SetChatPermissions<'a>
[src]

Sets a group's global permissions.

pub fn set_chat_photo<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    photo: ChatPhoto<'a>
) -> SetChatPhoto<'a>
[src]

Sets a chat's photo.

pub fn set_chat_sticker_set<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    sticker_set_name: &'a str
) -> SetChatStickerSet<'a>
[src]

Sets a group's sticker set.

pub fn set_chat_title<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    title: &'a str
) -> SetChatTitle<'a>
[src]

Sets a group's title.

pub fn set_inline_game_score<'a>(
    &'a self,
    inline_message_id: Ref<'a>,
    user_id: Id,
    score: u32
) -> SetInlineGameScore<'a>
[src]

Sets a user's new high score in a game sent via the inline mode.

pub fn set_message_game_score<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id,
    user_id: Id,
    score: u32
) -> SetMessageGameScore<'a>
[src]

Sets a user's new high score in a game sent by the bot itself.

pub fn set_my_commands<'a>(
    &'a self,
    commands: &'a [BotCommand<'a>]
) -> SetMyCommands<'a>
[src]

Sets the list of the bot's commands.

pub fn set_passport_data_errors<'a>(
    &'a self,
    user_id: Id,
    errors: &'a [Error<'a>]
) -> SetPassportDataErrors<'a>
[src]

Reports passport errors to the user.

pub fn set_sticker_position_in_set<'a>(
    &'a self,
    sticker: &'a str,
    position: u32
) -> SetStickerPositionInSet<'a>
[src]

Changes a sticker's position in a sticker set.

pub fn set_sticker_set_thumb<'a>(
    &'a self,
    user_id: Id,
    name: &'a str,
    thumb: Option<&'a StickerSetThumb<'a>>
) -> SetStickerSetThumb<'a>
[src]

Sets the thumb of a sticker set.

pub fn stop_inline_location<'a>(
    &'a self,
    inline_message_id: Ref<'a>
) -> StopInlineLocation<'a>
[src]

Stops a live location sent via the inline mode.

pub fn stop_message_location<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id
) -> StopMessageLocation<'a>
[src]

Stops a live location sent by the bot itself.

pub fn stop_poll<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    message_id: Id
) -> StopPoll<'a>
[src]

Stops a poll.

pub fn unban_chat_member<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>,
    user_id: Id
) -> UnbanChatMember<'a>
[src]

Lifts all restrictions from a group's member.

pub fn unpin_chat_message<'a>(
    &'a self,
    chat_id: impl ImplicitChatId<'a>
) -> UnpinChatMessage<'a>
[src]

Unpins a chat message.

pub fn upload_sticker_file<'a>(
    &'a self,
    user_id: Id,
    png_sticker: &'a [u8]
) -> UploadStickerFile<'a>
[src]

Uploads a sticker file.

Trait Implementations

impl ChatActionLoopBotExt for Bot[src]

impl Clone for Bot[src]

impl Debug for Bot[src]

Auto Trait Implementations

impl !RefUnwindSafe for Bot

impl Send for Bot

impl Sync for Bot

impl Unpin for Bot

impl !UnwindSafe for Bot

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]