Module tbot::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);

let bot = tbot::from_env!("BOT_TOKEN");
let message = Text::with_markdown("`tbot` is a super-cool crate!");
bot.send_message(CHAT, 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

Adds a new sticker to an existing sticker set.
Answers a callback query.
Answers an inline query.
Answers a pre-checkout query.
Answers a shipping query.
Bans a member in a chat.
Copies a message.
Creates a secondary invite link for a chat.
Creates a new sticker set.
Deletes a chat’s photo.
Deletes a chat’s sticker set.
Deletes a message from a chat.
Deletes the list of the bot’s commands.
Deletes a sticker from a sticker set.
Edits a secondary invite link for a chat.
Edits the caption of a media message sent via the inline mode.
Edits a live location sent via the inline mode.
Edits the media of a message sent via the inline mode.
Edits the inline keyboard of a message sent via the inline mode.
Edits the text of a message sent via the inline mode.
Edits the caption of a media message sent by the bot itself.
Edits a live location sent by the bot itself.
Edits the media of a message sent by the bot itself.
Edits the inline keyboard of a message sent by the bot itself.
Edits the text of a message sent by the bot itself.
Exports a chat’s invite link.
Forwards a message.
Gets information about a chat.
Gets information about a chat’s admins.
Gets information about a chat’s member.
Gets a chat’s member count.
Gets information about a file.
Gets an excerpt from the high score table of a game sent via the inline mode.
Gets information about the bot.
Gets an excerpt from the high score table of a game sent by the bot itself.
Gets the list of the bot’s commands.
Gets a sticker set by its name.
Gets a user’s profile photos.
Gets information about the bot’s webhook.
Leaves a chat.
Pins a message in a chat.
Promotes a chat member to an admin.
Restricts a chat member.
Revokes an invite link for a chat.
Sends an animation.
Sends an audio.
Sends a chat action.
Sends a contact.
Sends a dice.
Sends a document.
Sends a game.
Sends an invoice.
Sends a location.
Sends an album.
Sends a text message.
Sends a photo.
Sends a poll.
Sends a sticker.
Sends a venue.
Sends a video.
Sends a video note.
Sends a voice.
Sets a custom title for an admin in a supergroup promoted by the bot.
Sets a chat’s description.
Sets a group’s global permissions.
Sets a chat’s photo.
Sets a group’s sticker set.
Sets a group’s title.
Sets a user’s new high score in a game sent via the inline mode.
Sets a user’s new high score in a game sent by the bot itself.
Sets the list of the bot’s commands.
Reports passport errors to the user.
Changes a sticker’s position in a sticker set.
Sets the thumb of a sticker set.
Stops a live location sent via the inline mode.
Stops a live location sent by the bot itself.
Stops a poll.
Lifts all restrictions from a group’s member.
Unpins all messages in a chat.
Unpins a chat message.
Uploads a sticker file.