Skip to main content

BotClient

Struct BotClient 

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

The Telegram Bot API HTTP client.

BotClient is cheap to clone — all internal state is reference-counted. It is safe to share across tasks and threads without additional synchronisation.

§Creating a client

// From a token string (simplest)
let client = BotClient::from_token("123456:ABC...")?;

// From a ClientConfig for advanced options
let config = ClientConfig::new("123456:ABC...")?
    .api_base_url("http://localhost:8081")
    .timeout(Duration::from_secs(60));
let client = BotClient::new(config)?;

§Making API calls

Every Bot API method is available as a method on BotClient. Each method returns a builder — set optional parameters with chained calls, then .await to execute:

client
    .send_message(chat_id, "Hello!")
    .parse_mode(ParseMode::HTML)
    .disable_notification(true)
    .await?;

Implementations§

Source§

impl BotClient

Source

pub fn new(config: ClientConfig) -> Result<Self>

Creates a new BotClient from a ClientConfig.

§Errors

Returns an error if the underlying HTTP client cannot be initialised.

Source

pub fn from_token(token: impl Into<String>) -> Result<Self>

Creates a BotClient directly from a bot token string.

This is equivalent to BotClient::new(ClientConfig::new(token)?).

§Errors

Returns Error::InvalidToken if the token format is invalid.

Source

pub fn token(&self) -> &str

Returns the bot token used for authentication.

Source

pub fn api_base_url(&self) -> &str

Returns the base URL used for API requests, defaulting to https://api.telegram.org.

Source

pub async fn post_json<P, R>(&self, method: &str, params: &P) -> Result<R>

Sends a JSON POST request to a Bot API method and deserialises the result.

Automatically retries on HTTP 429 (flood control) up to max_retries times, waiting the retry_after duration between attempts.

Byte uploads take post_multipart instead, which does not retry.

§Errors

Returns an error on network failure, API error (ok: false), or deserialisation failure.

Source

pub async fn post_multipart<R>(&self, method: &str, form: Form) -> Result<R>

Sends a multipart/form-data POST request to a Bot API method and deserialises the result.

Unlike post_json this does not retry on flood control, regardless of ClientConfig::max_retries: the form is consumed by the send and cannot be rebuilt for another attempt. A 429 surfaces immediately as Error::RateLimit.

Source

pub async fn download_file(&self, file_path: &str) -> Result<Bytes>

Downloads a file by its path as returned by BotClient::get_file.

The file path must be obtained by calling get_file first:

let file = client.get_file(&document.file_id).await?;
let bytes = client.download_file(&file.file_path.unwrap()).await?;

Maximum file size via the Telegram cloud server is 20 MB. Use a local Bot API server to lift this restriction.

Source

pub fn get_updates(&self) -> GetUpdates

Calls getUpdates — fetches a batch of incoming updates via long polling.

Source

pub fn set_webhook(&self, url: impl Into<String>) -> SetWebhook

Calls setWebhook — registers a webhook URL with Telegram.

Source

pub fn delete_webhook(&self) -> DeleteWebhook

Calls deleteWebhook — removes the webhook integration.

Source

pub fn get_webhook_info(&self) -> GetWebhookInfo

Calls getWebhookInfo — returns the current webhook status.

Source

pub fn get_me(&self) -> GetMe

Calls getMe — returns basic information about the bot.

Source

pub fn get_chat(&self, chat_id: impl Into<ChatId>) -> GetChat

Calls getChat — returns detailed information about a chat.

Source

pub fn get_chat_administrators( &self, chat_id: impl Into<ChatId>, ) -> GetChatAdministrators

Calls getChatAdministrators — returns a list of all chat administrators.

Source

pub fn get_chat_member_count( &self, chat_id: impl Into<ChatId>, ) -> GetChatMemberCount

Calls getChatMemberCount — returns the number of members in a chat.

Source

pub fn get_chat_member( &self, chat_id: impl Into<ChatId>, user_id: i64, ) -> GetChatMember

Calls getChatMember — returns information about a specific chat member.

Source

pub fn get_file(&self, file_id: impl Into<String>) -> GetFile

Calls getFile — returns file metadata and a download path.

Source

pub fn get_user_profile_photos(&self, user_id: i64) -> GetUserProfilePhotos

Calls getUserProfilePhotos — returns a user’s profile pictures.

Source

pub fn get_user_profile_audios(&self, user_id: i64) -> GetUserProfileAudios

Calls getUserProfileAudios — returns audios displayed on a user’s profile (Bot API 9.4).

Source

pub fn get_user_personal_chat_messages( &self, user_id: i64, limit: u32, ) -> GetUserPersonalChatMessages

Calls getUserPersonalChatMessages — returns the last messages from a user’s personal chat (Bot API 9.7).

limit must be between 1 and 20.

Source

pub fn send_message( &self, chat_id: impl Into<ChatId>, text: impl Into<String>, ) -> SendMessage

Calls sendMessage — sends a text message to a chat.

Source

pub fn forward_message( &self, chat_id: impl Into<ChatId>, from_chat_id: impl Into<ChatId>, message_id: i64, ) -> ForwardMessage

Calls forwardMessage — forwards a message from one chat to another.

Source

pub fn copy_message( &self, chat_id: impl Into<ChatId>, from_chat_id: impl Into<ChatId>, message_id: i64, ) -> CopyMessage

Calls copyMessage — copies a message without the forward header.

Source

pub fn send_chat_action( &self, chat_id: impl Into<ChatId>, action: ChatAction, ) -> SendChatAction

Calls sendChatAction — displays a typing or upload indicator.

Source

pub fn send_photo( &self, chat_id: impl Into<ChatId>, photo: InputFile, ) -> SendPhoto

Calls sendPhoto — sends a photo.

Source

pub fn send_live_photo( &self, chat_id: impl Into<ChatId>, live_photo: InputFile, photo: InputFile, ) -> SendLivePhoto

Calls sendLivePhoto — sends a live photo (Bot API 9.7).

live_photo is the video component; photo is the static preview. Sending by URL is currently unsupported — use InputFile::FileId or InputFile::Bytes.

Source

pub fn send_audio( &self, chat_id: impl Into<ChatId>, audio: InputFile, ) -> SendAudio

Calls sendAudio — sends an audio file treated as music.

Source

pub fn send_document( &self, chat_id: impl Into<ChatId>, document: InputFile, ) -> SendDocument

Calls sendDocument — sends a general file.

Source

pub fn send_video( &self, chat_id: impl Into<ChatId>, video: InputFile, ) -> SendVideo

Calls sendVideo — sends a video file.

Source

pub fn send_animation( &self, chat_id: impl Into<ChatId>, animation: InputFile, ) -> SendAnimation

Calls sendAnimation — sends a GIF or silent H.264 video.

Source

pub fn send_voice( &self, chat_id: impl Into<ChatId>, voice: InputFile, ) -> SendVoice

Calls sendVoice — sends a voice note.

Source

pub fn send_video_note( &self, chat_id: impl Into<ChatId>, video_note: InputFile, ) -> SendVideoNote

Calls sendVideoNote — sends a rounded-square video.

Source

pub fn send_sticker( &self, chat_id: impl Into<ChatId>, sticker: InputFile, ) -> SendSticker

Calls sendSticker — sends a sticker.

Source

pub fn send_location( &self, chat_id: impl Into<ChatId>, latitude: f64, longitude: f64, ) -> SendLocation

Calls sendLocation — sends a geographic location, optionally live.

Source

pub fn send_contact( &self, chat_id: impl Into<ChatId>, phone_number: impl Into<String>, first_name: impl Into<String>, ) -> SendContact

Calls sendContact — sends a phone contact.

Source

pub fn send_poll( &self, chat_id: impl Into<ChatId>, question: impl Into<String>, options: Vec<InputPollOption>, ) -> SendPoll

Calls sendPoll — sends a native poll or quiz.

Source

pub fn send_dice(&self, chat_id: impl Into<ChatId>) -> SendDice

Calls sendDice — sends an animated random emoji.

Source

pub fn send_venue( &self, chat_id: impl Into<ChatId>, latitude: f64, longitude: f64, title: impl Into<String>, address: impl Into<String>, ) -> SendVenue

Calls sendVenue — sends information about a venue.

Source

pub fn forward_messages( &self, chat_id: impl Into<ChatId>, from_chat_id: impl Into<ChatId>, message_ids: Vec<i64>, ) -> ForwardMessages

Calls forwardMessages — forwards 1–100 messages at once, preserving album grouping.

Source

pub fn copy_messages( &self, chat_id: impl Into<ChatId>, from_chat_id: impl Into<ChatId>, message_ids: Vec<i64>, ) -> CopyMessages

Calls copyMessages — copies 1–100 messages without a forward link, preserving album grouping.

Source

pub fn send_media_group( &self, chat_id: impl Into<ChatId>, media: Vec<InputMedia>, ) -> SendMediaGroup

Calls sendMediaGroup — sends 2–10 photos, videos, documents, or audios as an album.

Source

pub fn send_paid_media( &self, chat_id: impl Into<ChatId>, star_count: u32, media: Vec<InputPaidMedia>, ) -> SendPaidMedia

Calls sendPaidMedia — sends paid media requiring Telegram Stars to view.

Source

pub fn send_game( &self, chat_id: i64, game_short_name: impl Into<String>, ) -> SendGame

Calls sendGame — sends an HTML5 game.

Source

pub fn send_checklist( &self, business_connection_id: impl Into<String>, chat_id: i64, checklist: InputChecklist, ) -> SendChecklist

Calls sendChecklist — sends a checklist on behalf of a business account.

Source

pub fn send_message_draft( &self, chat_id: impl Into<ChatId>, draft_id: i64, text: impl Into<String>, ) -> SendMessageDraft

Calls sendMessageDraft — streams a partial message (Bot API 9.5+).

Source

pub fn send_rich_message( &self, chat_id: impl Into<ChatId>, rich_message: InputRichMessage, ) -> SendRichMessage

Calls sendRichMessage — sends a rich formatted message (Bot API 10.1).

Source

pub fn send_rich_message_draft( &self, chat_id: i64, draft_id: i64, rich_message: InputRichMessage, ) -> SendRichMessageDraft

Calls sendRichMessageDraft — streams a partial rich message as an ephemeral preview (Bot API 10.1).

The draft expires after 30 seconds. Call send_rich_message with the completed content to persist it.

Source

pub fn delete_message( &self, chat_id: impl Into<ChatId>, message_id: i64, ) -> DeleteMessage

Calls deleteMessage — deletes a message.

Source

pub fn delete_messages( &self, chat_id: impl Into<ChatId>, message_ids: Vec<i64>, ) -> DeleteMessages

Calls deleteMessages — deletes up to 100 messages at once.

Source

pub fn delete_ephemeral_message( &self, chat_id: impl Into<ChatId>, receiver_user_id: i64, ephemeral_message_id: i64, ) -> DeleteEphemeralMessage

Calls deleteEphemeralMessage — deletes an ephemeral message (Bot API 10.2).

Source

pub fn stop_poll(&self, chat_id: impl Into<ChatId>, message_id: i64) -> StopPoll

Calls stopPoll — stops an open poll.

Source

pub fn answer_callback_query( &self, callback_query_id: impl Into<String>, ) -> AnswerCallbackQuery

Calls answerCallbackQuery — acknowledges a callback button press.

Source

pub fn edit_message_text( &self, chat_id: impl Into<ChatId>, message_id: i64, text: impl Into<String>, ) -> EditMessageText

Calls editMessageText — edits the text of a sent message.

Source

pub fn edit_inline_message_text( &self, inline_message_id: impl Into<String>, text: impl Into<String>, ) -> EditMessageText

Calls editMessageText for an inline message sent via inline mode.

Source

pub fn edit_message_rich_text( &self, chat_id: impl Into<ChatId>, message_id: i64, rich_message: InputRichMessage, ) -> EditMessageText

Calls editMessageText to replace a chat message with rich formatted content.

Source

pub fn edit_inline_message_rich_text( &self, inline_message_id: impl Into<String>, rich_message: InputRichMessage, ) -> EditMessageText

Calls editMessageText to replace an inline message with rich formatted content.

Source

pub fn edit_message_caption( &self, chat_id: impl Into<ChatId>, message_id: i64, ) -> EditMessageCaption

Calls editMessageCaption — edits the caption of a media message.

Source

pub fn edit_inline_message_caption( &self, inline_message_id: impl Into<String>, ) -> EditMessageCaption

Calls editMessageCaption for an inline message sent via inline mode.

Source

pub fn edit_message_media( &self, chat_id: impl Into<ChatId>, message_id: i64, media: InputMedia, ) -> EditMessageMedia

Calls editMessageMedia — replaces the media content of a message.

Source

pub fn edit_inline_message_media( &self, inline_message_id: impl Into<String>, media: InputMedia, ) -> EditMessageMedia

Calls editMessageMedia for an inline message sent via inline mode.

Source

pub fn edit_message_reply_markup( &self, chat_id: impl Into<ChatId>, message_id: i64, ) -> EditMessageReplyMarkup

Calls editMessageReplyMarkup — replaces the inline keyboard of a message.

Source

pub fn edit_inline_message_reply_markup( &self, inline_message_id: impl Into<String>, ) -> EditMessageReplyMarkup

Calls editMessageReplyMarkup for an inline message sent via inline mode.

Source

pub fn edit_ephemeral_message_text( &self, chat_id: impl Into<ChatId>, receiver_user_id: i64, ephemeral_message_id: i64, text: impl Into<String>, ) -> EditEphemeralMessageText

Calls editEphemeralMessageText — edits the text of an ephemeral message (Bot API 10.2).

Source

pub fn edit_ephemeral_message_caption( &self, chat_id: impl Into<ChatId>, receiver_user_id: i64, ephemeral_message_id: i64, ) -> EditEphemeralMessageCaption

Calls editEphemeralMessageCaption — edits the caption of an ephemeral message (Bot API 10.2).

Source

pub fn edit_ephemeral_message_media( &self, chat_id: impl Into<ChatId>, receiver_user_id: i64, ephemeral_message_id: i64, media: InputMedia, ) -> EditEphemeralMessageMedia

Calls editEphemeralMessageMedia — replaces the media of an ephemeral message.

Delivery of the edit is not guaranteed, particularly if the receiving user is offline.

Source

pub fn edit_ephemeral_message_reply_markup( &self, chat_id: impl Into<ChatId>, receiver_user_id: i64, ephemeral_message_id: i64, ) -> EditEphemeralMessageReplyMarkup

Calls editEphemeralMessageReplyMarkup — replaces the inline keyboard of an ephemeral message (Bot API 10.2).

Source

pub fn edit_message_checklist( &self, business_connection_id: impl Into<String>, chat_id: i64, message_id: i64, checklist: InputChecklist, ) -> EditMessageChecklist

Calls editMessageChecklist — edits a checklist on behalf of a business account.

Source

pub fn approve_suggested_post( &self, chat_id: i64, message_id: i64, ) -> ApproveSuggestedPost

Calls approveSuggestedPost — approves a suggested post in a direct messages chat.

Source

pub fn decline_suggested_post( &self, chat_id: i64, message_id: i64, ) -> DeclineSuggestedPost

Calls declineSuggestedPost — declines a suggested post in a direct messages chat.

Source

pub fn edit_message_live_location( &self, chat_id: impl Into<ChatId>, message_id: i64, latitude: f64, longitude: f64, ) -> EditMessageLiveLocation

Calls editMessageLiveLocation — updates the position of a live location.

Source

pub fn edit_inline_message_live_location( &self, inline_message_id: impl Into<String>, latitude: f64, longitude: f64, ) -> EditMessageLiveLocation

Calls editMessageLiveLocation for an inline message sent via inline mode.

Source

pub fn stop_message_live_location( &self, chat_id: impl Into<ChatId>, message_id: i64, ) -> StopMessageLiveLocation

Calls stopMessageLiveLocation — stops a live location from updating.

Source

pub fn stop_inline_message_live_location( &self, inline_message_id: impl Into<String>, ) -> StopMessageLiveLocation

Calls stopMessageLiveLocation for an inline message sent via inline mode.

Source

pub fn ban_chat_member( &self, chat_id: impl Into<ChatId>, user_id: i64, ) -> BanChatMember

Calls banChatMember — bans a user from a chat.

Source

pub fn unban_chat_member( &self, chat_id: impl Into<ChatId>, user_id: i64, ) -> UnbanChatMember

Calls unbanChatMember — lifts a ban from a user.

Source

pub fn restrict_chat_member( &self, chat_id: impl Into<ChatId>, user_id: i64, permissions: ChatPermissions, ) -> RestrictChatMember

Calls restrictChatMember — restricts what a user can do in a chat.

Source

pub fn promote_chat_member( &self, chat_id: impl Into<ChatId>, user_id: i64, ) -> PromoteChatMember

Calls promoteChatMember — grants or revokes admin privileges.

Source

pub fn set_chat_administrator_custom_title( &self, chat_id: impl Into<ChatId>, user_id: i64, custom_title: impl Into<String>, ) -> SetChatAdministratorCustomTitle

Calls setChatAdministratorCustomTitle — sets a custom title for an admin.

Source

pub fn set_chat_member_tag( &self, chat_id: impl Into<ChatId>, user_id: i64, ) -> SetChatMemberTag

Calls setChatMemberTag — sets a tag for a regular member (Bot API 9.5).

Source

pub fn set_chat_permissions( &self, chat_id: impl Into<ChatId>, permissions: ChatPermissions, ) -> SetChatPermissions

Calls setChatPermissions — sets default chat permissions for all members.

Calls exportChatInviteLink — generates a new primary invite link, revoking the old one.

Calls createChatInviteLink — generates a new additional invite link.

Calls editChatInviteLink — edits a non-primary invite link created by the bot.

Calls revokeChatInviteLink — revokes an invite link created by the bot.

Calls createChatSubscriptionInviteLink — creates a subscription invite link for a channel.

Calls editChatSubscriptionInviteLink — edits a subscription invite link.

Source

pub fn approve_chat_join_request( &self, chat_id: impl Into<ChatId>, user_id: i64, ) -> ApproveChatJoinRequest

Calls approveChatJoinRequest — approves a pending join request.

Source

pub fn decline_chat_join_request( &self, chat_id: impl Into<ChatId>, user_id: i64, ) -> DeclineChatJoinRequest

Calls declineChatJoinRequest — declines a pending join request.

Source

pub fn answer_chat_join_request_query( &self, chat_join_request_query_id: impl Into<String>, result: JoinRequestResult, ) -> AnswerChatJoinRequestQuery

Calls answerChatJoinRequestQuery — processes a join request query (Bot API 10.1).

Must be called within 10 seconds of receiving a ChatJoinRequest that carries a query_id.

Source

pub fn send_chat_join_request_web_app( &self, chat_join_request_query_id: impl Into<String>, web_app_url: impl Into<String>, ) -> SendChatJoinRequestWebApp

Calls sendChatJoinRequestWebApp — shows a Mini App to the user before deciding (Bot API 10.1).

Must be called within 10 seconds of receiving a ChatJoinRequest that carries a query_id.

Source

pub fn ban_chat_sender_chat( &self, chat_id: impl Into<ChatId>, sender_chat_id: i64, ) -> BanChatSenderChat

Calls banChatSenderChat — bans a channel chat from sending in a supergroup or channel.

Source

pub fn unban_chat_sender_chat( &self, chat_id: impl Into<ChatId>, sender_chat_id: i64, ) -> UnbanChatSenderChat

Calls unbanChatSenderChat — unbans a previously banned channel chat.

Source

pub fn unpin_all_chat_messages( &self, chat_id: impl Into<ChatId>, ) -> UnpinAllChatMessages

Calls unpinAllChatMessages — clears all pinned messages in a chat.

Source

pub fn set_chat_photo( &self, chat_id: impl Into<ChatId>, photo: InputFile, ) -> SetChatPhoto

Calls setChatPhoto — sets a new profile photo for the chat.

Source

pub fn delete_chat_photo(&self, chat_id: impl Into<ChatId>) -> DeleteChatPhoto

Calls deleteChatPhoto — deletes the chat photo.

Source

pub fn set_chat_title( &self, chat_id: impl Into<ChatId>, title: impl Into<String>, ) -> SetChatTitle

Calls setChatTitle — changes the title of a chat.

Source

pub fn set_chat_description( &self, chat_id: impl Into<ChatId>, ) -> SetChatDescription

Calls setChatDescription — changes the description of a group, supergroup, or channel.

Source

pub fn set_chat_sticker_set( &self, chat_id: impl Into<ChatId>, sticker_set_name: impl Into<String>, ) -> SetChatStickerSet

Calls setChatStickerSet — sets the sticker set for a supergroup.

Source

pub fn delete_chat_sticker_set( &self, chat_id: impl Into<ChatId>, ) -> DeleteChatStickerSet

Calls deleteChatStickerSet — removes the sticker set from a supergroup.

Source

pub fn leave_chat(&self, chat_id: impl Into<ChatId>) -> LeaveChat

Calls leaveChat — makes the bot leave a group, supergroup, or channel.

Source

pub fn get_user_chat_boosts( &self, chat_id: impl Into<ChatId>, user_id: i64, ) -> GetUserChatBoosts

Calls getUserChatBoosts — returns the boosts added to a chat by a user.

Source

pub fn pin_chat_message( &self, chat_id: impl Into<ChatId>, message_id: i64, ) -> PinChatMessage

Calls pinChatMessage — pins a message in a chat.

Source

pub fn unpin_chat_message(&self, chat_id: impl Into<ChatId>) -> UnpinChatMessage

Calls unpinChatMessage — unpins a message in a chat.

Source

pub fn log_out(&self) -> LogOut

Calls logOut — logs the bot out of the cloud Bot API server.

Source

pub fn close(&self) -> Close

Calls close — closes the bot instance before moving it to another server.

Source

pub fn set_my_commands(&self, commands: Vec<BotCommand>) -> SetMyCommands

Calls setMyCommands — sets the bot’s command list.

Source

pub fn delete_my_commands(&self) -> DeleteMyCommands

Calls deleteMyCommands — deletes the bot’s command list for a given scope and language.

Source

pub fn get_my_commands(&self) -> GetMyCommands

Calls getMyCommands — returns the bot’s current command list.

Source

pub fn set_my_name(&self) -> SetMyName

Calls setMyName — changes the bot’s display name.

Source

pub fn get_my_name(&self) -> GetMyName

Calls getMyName — returns the bot’s current display name.

Source

pub fn set_my_description(&self) -> SetMyDescription

Calls setMyDescription — changes the bot’s profile description.

Source

pub fn get_my_description(&self) -> GetMyDescription

Calls getMyDescription — returns the bot’s current profile description.

Source

pub fn set_my_short_description(&self) -> SetMyShortDescription

Calls setMyShortDescription — changes the bot’s short description.

Source

pub fn get_my_short_description(&self) -> GetMyShortDescription

Calls getMyShortDescription — returns the bot’s current short description.

Source

pub fn set_my_default_administrator_rights( &self, ) -> SetMyDefaultAdministratorRights

Calls setMyDefaultAdministratorRights — sets the default admin rights suggested to users.

Source

pub fn get_my_default_administrator_rights( &self, ) -> GetMyDefaultAdministratorRights

Calls getMyDefaultAdministratorRights — returns the bot’s current default admin rights.

Source

pub fn get_chat_menu_button(&self) -> GetChatMenuButton

Calls getChatMenuButton — returns the current menu button for a private chat.

Source

pub fn set_chat_menu_button(&self) -> SetChatMenuButton

Calls setChatMenuButton — changes the bot’s menu button in a private chat or globally.

Source

pub fn set_my_profile_photo( &self, photo: InputProfilePhoto, ) -> SetMyProfilePhoto

Calls setMyProfilePhoto — changes the bot’s profile photo (Bot API 9.4).

Source

pub fn remove_my_profile_photo(&self) -> RemoveMyProfilePhoto

Calls removeMyProfilePhoto — removes the bot’s current profile photo (Bot API 9.4).

Source

pub fn get_managed_bot_token(&self, user_id: i64) -> GetManagedBotToken

Calls getManagedBotToken — returns the token of a managed bot (Bot API 9.6).

Source

pub fn replace_managed_bot_token(&self, user_id: i64) -> ReplaceManagedBotToken

Calls replaceManagedBotToken — revokes and regenerates a managed bot’s token (Bot API 9.6).

Source

pub fn get_managed_bot_access_settings( &self, user_id: i64, ) -> GetManagedBotAccessSettings

Calls getManagedBotAccessSettings — returns the access settings of a managed bot (Bot API 9.7).

Source

pub fn set_managed_bot_access_settings( &self, user_id: i64, is_access_restricted: bool, ) -> SetManagedBotAccessSettings

Calls setManagedBotAccessSettings — changes the access settings of a managed bot (Bot API 9.7).

Source

pub fn post_story( &self, business_connection_id: impl Into<String>, content: InputStoryContent, active_period: u32, ) -> PostStory

Calls postStory — posts a story on behalf of a managed business account.

active_period must be one of 21600, 43200, 86400, or 172800 seconds.

Source

pub fn repost_story( &self, business_connection_id: impl Into<String>, from_chat_id: i64, from_story_id: i64, active_period: u32, ) -> RepostStory

Calls repostStory — reposts a story from one managed business account to another.

active_period must be one of 21600, 43200, 86400, or 172800 seconds.

Source

pub fn edit_story( &self, business_connection_id: impl Into<String>, story_id: i64, content: InputStoryContent, ) -> EditStory

Calls editStory — edits a story posted by the bot on behalf of a business account.

Source

pub fn delete_story( &self, business_connection_id: impl Into<String>, story_id: i64, ) -> DeleteStory

Calls deleteStory — deletes a story posted by the bot on behalf of a business account.

Source

pub fn get_available_gifts(&self) -> GetAvailableGifts

Calls getAvailableGifts — returns all gifts the bot can send.

Source

pub fn send_gift(&self, gift_id: impl Into<String>) -> SendGift

Calls sendGift — sends a gift to a user or channel chat.

Chain .user_id(id) or .chat_id(id) to specify the recipient.

Source

pub fn gift_premium_subscription( &self, user_id: i64, month_count: u32, star_count: u32, ) -> GiftPremiumSubscription

Calls giftPremiumSubscription — gifts a Telegram Premium subscription to a user.

month_count must be 3, 6, or 12. star_count must be 1000, 1500, or 2500 respectively.

Source

pub fn get_business_account_gifts( &self, business_connection_id: impl Into<String>, ) -> GetBusinessAccountGifts

Calls getBusinessAccountGifts — returns gifts received by a managed business account.

Source

pub fn get_user_gifts(&self, user_id: i64) -> GetUserGifts

Calls getUserGifts — returns gifts owned by a user.

Source

pub fn get_chat_gifts(&self, chat_id: impl Into<ChatId>) -> GetChatGifts

Calls getChatGifts — returns gifts owned by a channel chat.

Source

pub fn convert_gift_to_stars( &self, business_connection_id: impl Into<String>, owned_gift_id: impl Into<String>, ) -> ConvertGiftToStars

Calls convertGiftToStars — converts a business account gift to Telegram Stars.

Source

pub fn upgrade_gift( &self, business_connection_id: impl Into<String>, owned_gift_id: impl Into<String>, ) -> UpgradeGift

Calls upgradeGift — upgrades a regular gift to a unique gift.

Source

pub fn transfer_gift( &self, business_connection_id: impl Into<String>, owned_gift_id: impl Into<String>, new_owner_chat_id: i64, ) -> TransferGift

Calls transferGift — transfers a unique gift to another user.

Source

pub fn set_message_reaction( &self, chat_id: impl Into<ChatId>, message_id: i64, ) -> SetMessageReaction

Calls setMessageReaction — sets a reaction on a message.

Source

pub fn delete_message_reaction( &self, chat_id: impl Into<ChatId>, message_id: i64, ) -> DeleteMessageReaction

Calls deleteMessageReaction — removes a specific reaction from a message (Bot API 9.7).

Source

pub fn delete_all_message_reactions( &self, chat_id: impl Into<ChatId>, ) -> DeleteAllMessageReactions

Calls deleteAllMessageReactions — removes all recent reactions by a given user or chat (Bot API 9.7).

Source

pub fn answer_inline_query( &self, inline_query_id: impl Into<String>, results: Vec<InlineQueryResult>, ) -> AnswerInlineQuery

Calls answerInlineQuery — sends up to 50 results for an inline query.

Source

pub fn answer_web_app_query( &self, web_app_query_id: impl Into<String>, result: InlineQueryResult, ) -> AnswerWebAppQuery

Calls answerWebAppQuery — sets the result of a Web App interaction and sends it to the chat.

Source

pub fn answer_guest_query( &self, guest_query_id: impl Into<String>, result: InlineQueryResult, ) -> AnswerGuestQuery

Calls answerGuestQuery — replies to a received guest message (Bot API 9.7).

Source

pub fn save_prepared_inline_message( &self, user_id: i64, result: InlineQueryResult, ) -> SavePreparedInlineMessage

Calls savePreparedInlineMessage — stores a message sendable by a Mini App user.

Source

pub fn save_prepared_keyboard_button( &self, user_id: i64, button: KeyboardButton, ) -> SavePreparedKeyboardButton

Calls savePreparedKeyboardButton — stores a keyboard button for use in a Mini App (Bot API 9.6).

The button must be of type request_users, request_chat, or request_managed_bot.

Source

pub fn set_user_emoji_status(&self, user_id: i64) -> SetUserEmojiStatus

Calls setUserEmojiStatus — changes a user’s emoji status via a Mini App.

Source

pub fn set_passport_data_errors( &self, user_id: i64, errors: Vec<PassportElementError>, ) -> SetPassportDataErrors

Calls setPassportDataErrors — reports errors in Telegram Passport elements.

Source

pub fn set_game_score(&self, user_id: i64, score: u32) -> SetGameScore

Calls setGameScore — sets a user’s score in a game.

Chain .chat_message(chat_id, message_id) or .inline_message_id(id) to target the message.

Source

pub fn get_game_high_scores(&self, user_id: i64) -> GetGameHighScores

Calls getGameHighScores — returns high scores for a game.

Chain .chat_message(chat_id, message_id) or .inline_message_id(id) to target the message.

Source

pub fn send_invoice( &self, chat_id: impl Into<ChatId>, title: impl Into<String>, description: impl Into<String>, payload: impl Into<String>, currency: impl Into<String>, prices: Vec<LabeledPrice>, ) -> SendInvoice

Calls sendInvoice — sends a payment invoice.

Calls createInvoiceLink — creates a shareable payment link.

Source

pub fn answer_shipping_query( &self, shipping_query_id: impl Into<String>, ok: bool, ) -> AnswerShippingQuery

Calls answerShippingQuery — responds to a shipping query from a user.

Pass ok = true and provide shipping_options; or ok = false with an error_message.

Source

pub fn answer_pre_checkout_query( &self, pre_checkout_query_id: impl Into<String>, ok: bool, ) -> AnswerPreCheckoutQuery

Calls answerPreCheckoutQuery — confirms or rejects a pre-checkout query.

Must be called within 10 seconds of receiving the query.

Source

pub fn refund_star_payment( &self, user_id: i64, telegram_payment_charge_id: impl Into<String>, ) -> RefundStarPayment

Calls refundStarPayment — refunds a successful Telegram Stars payment.

Source

pub fn edit_user_star_subscription( &self, user_id: i64, telegram_payment_charge_id: impl Into<String>, is_canceled: bool, ) -> EditUserStarSubscription

Calls editUserStarSubscription — cancels or re-enables a Stars subscription.

Source

pub fn get_my_star_balance(&self) -> GetMyStarBalance

Calls getMyStarBalance — returns the bot’s Telegram Star balance.

Source

pub fn get_star_transactions(&self) -> GetStarTransactions

Calls getStarTransactions — returns the bot’s Star transaction history.

Source

pub fn get_sticker_set(&self, name: impl Into<String>) -> GetStickerSet

Calls getStickerSet — returns a sticker set by name.

Source

pub fn get_custom_emoji_stickers( &self, ids: Vec<impl Into<String>>, ) -> GetCustomEmojiStickers

Calls getCustomEmojiStickers — returns stickers for the given custom emoji IDs.

Source

pub fn upload_sticker_file( &self, user_id: i64, sticker: InputFile, format: StickerFormat, ) -> UploadStickerFile

Calls uploadStickerFile — uploads a sticker file for later use in a set.

Source

pub fn create_new_sticker_set( &self, user_id: i64, name: impl Into<String>, title: impl Into<String>, stickers: Vec<InputSticker>, ) -> CreateNewStickerSet

Calls createNewStickerSet — creates a new sticker set owned by a user.

Source

pub fn add_sticker_to_set( &self, user_id: i64, name: impl Into<String>, sticker: InputSticker, ) -> AddStickerToSet

Calls addStickerToSet — adds a new sticker to an existing set.

Source

pub fn set_sticker_position_in_set( &self, sticker: impl Into<String>, position: u32, ) -> SetStickerPositionInSet

Calls setStickerPositionInSet — moves a sticker to a new position in its set.

Source

pub fn delete_sticker_from_set( &self, sticker: impl Into<String>, ) -> DeleteStickerFromSet

Calls deleteStickerFromSet — removes a sticker from its set.

Source

pub fn set_sticker_emoji_list( &self, sticker: impl Into<String>, emoji_list: Vec<impl Into<String>>, ) -> SetStickerEmojiList

Calls setStickerEmojiList — updates the emoji list for a sticker.

Source

pub fn set_sticker_keywords( &self, sticker: impl Into<String>, ) -> SetStickerKeywords

Calls setStickerKeywords — updates the search keywords for a sticker.

Source

pub fn set_sticker_mask_position( &self, sticker: impl Into<String>, ) -> SetStickerMaskPosition

Calls setStickerMaskPosition — updates the mask position for a mask sticker.

Source

pub fn set_sticker_set_title( &self, name: impl Into<String>, title: impl Into<String>, ) -> SetStickerSetTitle

Calls setStickerSetTitle — renames a sticker set.

Source

pub fn delete_sticker_set(&self, name: impl Into<String>) -> DeleteStickerSet

Calls deleteStickerSet — deletes a sticker set created by the bot.

Source

pub fn replace_sticker_in_set( &self, user_id: i64, name: impl Into<String>, old_sticker: impl Into<String>, sticker: InputSticker, ) -> ReplaceStickerInSet

Calls replaceStickerInSet — replaces an existing sticker in a set with a new one.

Source

pub fn set_sticker_set_thumbnail( &self, name: impl Into<String>, user_id: i64, format: impl Into<String>, ) -> SetStickerSetThumbnail

Calls setStickerSetThumbnail — sets the thumbnail of a regular or mask sticker set.

format must be "static", "animated", or "video". Chain .thumbnail(file) to set the thumbnail; omit to drop it.

Source

pub fn set_custom_emoji_sticker_set_thumbnail( &self, name: impl Into<String>, ) -> SetCustomEmojiStickerSetThumbnail

Calls setCustomEmojiStickerSetThumbnail — sets the thumbnail of a custom emoji sticker set.

Chain .custom_emoji_id(id) to set the thumbnail emoji; omit to use the first sticker.

Source

pub fn get_forum_topic_icon_stickers(&self) -> GetForumTopicIconStickers

Calls getForumTopicIconStickers — returns all available forum topic icon stickers.

Source

pub fn create_forum_topic( &self, chat_id: impl Into<ChatId>, name: impl Into<String>, ) -> CreateForumTopic

Calls createForumTopic — creates a new topic in a forum supergroup.

Source

pub fn edit_forum_topic( &self, chat_id: impl Into<ChatId>, thread_id: i64, ) -> EditForumTopic

Calls editForumTopic — edits the name or icon of a forum topic.

Source

pub fn close_forum_topic( &self, chat_id: impl Into<ChatId>, thread_id: i64, ) -> CloseForumTopic

Calls closeForumTopic — closes an open forum topic.

Source

pub fn reopen_forum_topic( &self, chat_id: impl Into<ChatId>, thread_id: i64, ) -> ReopenForumTopic

Calls reopenForumTopic — reopens a closed forum topic.

Source

pub fn delete_forum_topic( &self, chat_id: impl Into<ChatId>, thread_id: i64, ) -> DeleteForumTopic

Calls deleteForumTopic — deletes a forum topic and all its messages.

Source

pub fn edit_general_forum_topic( &self, chat_id: impl Into<ChatId>, name: impl Into<String>, ) -> EditGeneralForumTopic

Calls editGeneralForumTopic — renames the General topic.

Source

pub fn close_general_forum_topic( &self, chat_id: impl Into<ChatId>, ) -> CloseGeneralForumTopic

Calls closeGeneralForumTopic — closes the General topic.

Source

pub fn reopen_general_forum_topic( &self, chat_id: impl Into<ChatId>, ) -> ReopenGeneralForumTopic

Calls reopenGeneralForumTopic — reopens the General topic.

Source

pub fn hide_general_forum_topic( &self, chat_id: impl Into<ChatId>, ) -> HideGeneralForumTopic

Calls hideGeneralForumTopic — hides the General topic from the topic list.

Source

pub fn unhide_general_forum_topic( &self, chat_id: impl Into<ChatId>, ) -> UnhideGeneralForumTopic

Calls unhideGeneralForumTopic — makes the General topic visible again.

Source

pub fn unpin_all_general_forum_topic_messages( &self, chat_id: impl Into<ChatId>, ) -> UnpinAllGeneralForumTopicMessages

Calls unpinAllGeneralForumTopicMessages — clears all pinned messages in the General forum topic.

Source

pub fn verify_user(&self, user_id: i64) -> VerifyUser

Calls verifyUser — verifies a user on behalf of the organisation.

Source

pub fn verify_chat(&self, chat_id: impl Into<ChatId>) -> VerifyChat

Calls verifyChat — verifies a chat on behalf of the organisation.

Source

pub fn remove_user_verification(&self, user_id: i64) -> RemoveUserVerification

Calls removeUserVerification — removes verification from a user.

Source

pub fn remove_chat_verification( &self, chat_id: impl Into<ChatId>, ) -> RemoveChatVerification

Calls removeChatVerification — removes verification from a chat.

Source

pub fn get_business_connection( &self, id: impl Into<String>, ) -> GetBusinessConnection

Calls getBusinessConnection — returns business connection information.

Source

pub fn read_business_message( &self, business_connection_id: impl Into<String>, chat_id: impl Into<ChatId>, message_id: i64, ) -> ReadBusinessMessage

Calls readBusinessMessage — marks a business account message as read.

Source

pub fn delete_business_messages( &self, business_connection_id: impl Into<String>, message_ids: Vec<i64>, ) -> DeleteBusinessMessages

Calls deleteBusinessMessages — deletes messages from a business account.

Source

pub fn set_business_account_name( &self, business_connection_id: impl Into<String>, first_name: impl Into<String>, last_name: Option<String>, ) -> SetBusinessAccountName

Calls setBusinessAccountName — sets the name of a managed business account.

Source

pub fn set_business_account_username( &self, business_connection_id: impl Into<String>, username: Option<String>, ) -> SetBusinessAccountUsername

Calls setBusinessAccountUsername — sets the username of a managed business account.

Source

pub fn set_business_account_bio( &self, business_connection_id: impl Into<String>, bio: Option<String>, ) -> SetBusinessAccountBio

Calls setBusinessAccountBio — sets the bio of a managed business account.

Source

pub fn get_business_account_star_balance( &self, business_connection_id: impl Into<String>, ) -> GetBusinessAccountStarBalance

Calls getBusinessAccountStarBalance — returns a business account’s Star balance.

Source

pub fn transfer_business_account_stars( &self, business_connection_id: impl Into<String>, star_count: u64, ) -> TransferBusinessAccountStars

Calls transferBusinessAccountStars — transfers Stars from a business account to the bot.

Source

pub fn unpin_all_forum_topic_messages( &self, chat_id: impl Into<ChatId>, thread_id: i64, ) -> UnpinAllForumTopicMessages

Calls unpinAllForumTopicMessages — clears all pinned messages in a forum topic.

Source

pub fn set_business_account_profile_photo( &self, business_connection_id: impl Into<String>, photo: InputProfilePhoto, ) -> SetBusinessAccountProfilePhoto

Calls setBusinessAccountProfilePhoto — sets the profile photo of a managed business account.

Pass photo as serde_json::to_value(&input_profile_photo).

Source

pub fn remove_business_account_profile_photo( &self, business_connection_id: impl Into<String>, ) -> RemoveBusinessAccountProfilePhoto

Calls removeBusinessAccountProfilePhoto — removes the profile photo of a managed business account.

Source

pub fn set_business_account_gift_settings( &self, business_connection_id: impl Into<String>, show_gift_button: bool, accepted_gift_types: AcceptedGiftTypes, ) -> SetBusinessAccountGiftSettings

Calls setBusinessAccountGiftSettings — changes gift privacy settings for a managed business account.

Trait Implementations§

Source§

impl Clone for BotClient

Source§

fn clone(&self) -> BotClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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