Skip to main content

Module methods

Module methods 

Source
Expand description

Structs for calling API methods.

The methods from this module can’t be constructed directly; instead, you construct them using a Bot instance which infers the underlying client and your bot’s token, or using contexts that infer even more information from the update, such as the chat ID.

All the methods have a common pattern:

  • Methods provide Builder API for optional parameters;
  • Methods have the asynchronous call method, which calls the method and resolves with a Result.

For example, here’s how to call SendMessage:

use tbot::types::{chat, parameters::Text};

const CHAT: chat::Id = chat::Id(0);
const MESSAGE: &str = "`tbot` is a super-cool crate!";

let bot = tbot::from_env!("BOT_TOKEN");
bot.send_message(CHAT, Text::markdown(MESSAGE)).call().await.unwrap();

§Inline/message methods

Several API methods accept either (chat_id and message_id) or inline_message_id, and their return type depends on the chosen parameters. For such methods, tbot provides two structs, e.g. for editMessageText there are EditMessageText which resolves to types::Message and EditInlineText which resolves to (). This brings a type-safer API wrapper, unlike if we only had one method which would resolve to (() | types::Message).

Structs§

AddStickerToSet
Adds a new sticker to an existing sticker set.
AnswerCallbackQuery
Answers a callback query.
AnswerInlineQuery
Answers an inline query.
AnswerPreCheckoutQuery
Answers a pre-checkout query.
AnswerShippingQuery
Answers a shipping query.
CreateNewStickerSet
Creates a new sticker set.
DeleteChatPhoto
Deletes a chat’s photo.
DeleteChatStickerSet
Deletes a chat’s sticker set.
DeleteMessage
Deletes a message from a chat.
DeleteStickerFromSet
Deletes a sticker from a sticker set.
EditInlineCaption
Edits the caption of a media message sent via the inline mode.
EditInlineLocation
Edits a live location sent via the inline mode.
EditInlineMedia
Edits the media of a message sent via the inline mode.
EditInlineReplyMarkup
Edits the inline keyboard of a message sent via the inline mode.
EditInlineText
Edits the text of a message sent via the inline mode.
EditMessageCaption
Edits the caption of a media message sent by the bot itself.
EditMessageLocation
Edits a live location sent by the bot itself.
EditMessageMedia
Edits the media of a message sent by the bot itself.
EditMessageReplyMarkup
Edits the inline keyboard of a message sent by the bot itself.
EditMessageText
Edits the text of a message sent by the bot itself.
ExportChatInviteLink
Exports a chat’s invite link.
ForwardMessage
Forwards a message.
GetChat
Gets information about a chat.
GetChatAdministrators
Gets information about a chat’s admins.
GetChatMember
Gets information about a chat’s member.
GetChatMembersCount
Gets a chat’s member count.
GetFile
Gets information about a file.
GetInlineGameHighScores
Gets an excerpt from the high score table of a game sent via the inline mode.
GetMe
Gets information about the bot.
GetMessageGameHighScores
Gets an excerpt from the high score table of a game sent by the bot itself.
GetMyCommands
Gets the list of the bot’s commands.
GetStickerSet
Gets a sticker set by its name.
GetUserProfilePhotos
Gets a user’s profile photos.
GetWebhookInfo
Gets information about the bot’s webhook.
KickChatMember
Kicks a member out of a chat.
LeaveChat
Leaves a chat.
PinChatMessage
Pins a message in a chat.
PromoteChatMember
Promotes a chat member to an admin.
RestrictChatMember
Restricts a chat member.
SendAnimation
Sends an animation.
SendAudio
Sends an audio.
SendChatAction
Sends a chat action.
SendContact
Sends a contact.
SendDice
Sends a dice.
SendDocument
Sends a document.
SendGame
Sends a game.
SendInvoice
Sends an invoice.
SendLocation
Sends a location.
SendMediaGroup
Sends an album.
SendMessage
Sends a text message.
SendPhoto
Sends a photo.
SendPoll
Sends a poll.
SendSticker
Sends a sticker.
SendVenue
Sends a venue.
SendVideo
Sends a video.
SendVideoNote
Sends a video note.
SendVoice
Sends a voice.
SetChatAdministratorCustomTitle
Sets a custom title for an admin in a supergroup promoted by the bot.
SetChatDescription
Sets a chat’s description.
SetChatPermissions
Sets a group’s global permissions.
SetChatPhoto
Sets a chat’s photo.
SetChatStickerSet
Sets a group’s sticker set.
SetChatTitle
Sets a group’s title.
SetInlineGameScore
Sets a user’s new high score in a game sent via the inline mode.
SetMessageGameScore
Sets a user’s new high score in a game sent by the bot itself.
SetMyCommands
Sets the list of the bot’s commands.
SetPassportDataErrors
Reports passport errors to the user.
SetStickerPositionInSet
Changes a sticker’s position in a sticker set.
SetStickerSetThumb
Sets the thumb of a sticker set.
StopInlineLocation
Stops a live location sent via the inline mode.
StopMessageLocation
Stops a live location sent by the bot itself.
StopPoll
Stops a poll.
UnbanChatMember
Lifts all restrictions from a group’s member.
UnpinChatMessage
Unpins a chat message.
UploadStickerFile
Uploads a sticker file.