[][src]Module tbot::methods

Structs for calling API methods.

The methods from this module are low-level: you have to pass everything a method needs to their new methods. More likely, you'd like to use Bot to infer your bot's token when calling methods. Moreover, when handling updates, their contexts provide methods that infer even more information from the update.

All the methods have a common pattern:

  • Methods are constructed using their new method. This methods accepts required parameters for this method;
  • Methods provide the builder pattern for optional parameters;
  • Methods implement the IntoFuture trait, so you need to turn a method into a future before actually calling the method.

For example, here's how to call SendMessage:

use tbot::{
    prelude::*,
    types::{chat, parameters::Text},
    Token,
};

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

let bot = tbot::bot!("BOT_TOKEN");

let request = bot.send_message(CHAT, Text::markdown(MESSAGE))
    .into_future()
    .map_err(|err| {
        dbg!(err);
    });

tbot::run(request);

You may see that we use tbot::run. It is a thin wrapper around tokio::run which doesn't require a Future::Item to be (). In addition, we also have tbot::spawn with the same mitigations.

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 () and EditInlineText which resolves to types::Message. This brings a more straightforward API wrapper, unlike if we only had one method which would resolve to (() | types::Message).

Structs

AddStickerToSet

Represents the addStickerToSet method.

AnswerCallbackQuery

Represents the answerCallbackQuery method.

AnswerInlineQuery

Represents the answerInlineQuery method.

AnswerPreCheckoutQuery

Represents the answerPreCheckoutQuery method.

AnswerShippingQuery

Represents the answerShippingQuery method.

CreateNewStickerSet

Represents the createNewStickerSet method.

DeleteChatPhoto

Represents the deleteChatPhoto method.

DeleteChatStickerSet

Represents the deleteChatStickerSet method.

DeleteMessage

Represents the deleteMessage method.

DeleteStickerFromSet

Represents the deleteStickerFromSet method

EditInlineCaption

Represents the editMessageCaption method for inline messages.

EditInlineLocation

Represents the editMessageLiveLocation method for inline messages.

EditInlineMedia

Represents the editMessageMedia method for inline messages.

EditInlineReplyMarkup

Represents the editMessageReplyMarkup method for inline messages.

EditInlineText

Represents the editMessageText method for inline messages.

EditMessageCaption

Represents the editMessageCaption method for chat messages.

EditMessageLocation

Represents the editMessageLiveLocation method for chat messages.

EditMessageMedia

Represents the editMessageMedia method for chat messages.

EditMessageReplyMarkup

Represents the editMessageReplyMarkup method for chat messsages.

EditMessageText

Represents the editMessageText method for chat messages.

ExportChatInviteLink

Represents the exportChatInviteLink method.

ForwardMessage

Represents the forwardMessage method.

GetChat

Represents the getChat method.

GetChatAdministrators

Represents the getChatAdministrators method.

GetChatMember

Represents the getChatMember method.

GetChatMembersCount

Represents the getChatMembersCount method.

GetFile

Represents the getfile method.

GetInlineGameHighScores

Represents the getGameHighScores method for inline messages.

GetMe

Represents the getMe method.

GetMessageGameHighScores

Represents the getGameHighScores method for chat messages.

GetStickerSet

Represents the getStickerSet method.

GetUserProfilePhotos

Represents the getUserProfilePhotos method.

GetWebhookInfo

Represents the getWebhookInfo method.

KickChatMember

Represents the kickChatMember method.

LeaveChat

Represents the leaveChat method.

PinChatMessage

Represents the pinChatMessage method.

PromoteChatMember

Represents the promoteChatMember method.

RestrictChatMember

Represents the restrictChatMember method.

SendAnimation

Represents the sendAnimation method.

SendAudio

Represents the sendAudio method.

SendChatAction

Represents the sendChatAction method.

SendContact

Represents the sendContact method.

SendDocument

Represents the sendDocument method.

SendGame

Represents the sendGame method.

SendInvoice

Represents the sendInvoice method.

SendLocation

Represents the sendLocation method.

SendMediaGroup

Represents the sendMediaGroup method.

SendMessage

Represents the sendMessage method.

SendPhoto

Represents the sendPhoto method.

SendPoll

Represents the sendPoll method.

SendSticker

Represents the sendSticker method.

SendVenue

Represents the sendVenue method.

SendVideo

Represents the sendVideo method.

SendVideoNote

Represents the sendVideoNote method.

SendVoice

Represents the sendVoice method.

SetChatDescription

Represents the setChatDescription method.

SetChatPermissions

Represents the setChatPermissions method.

SetChatPhoto

Represents the setChatPhoto method.

SetChatStickerSet

Represents the setChatStickerSet method.

SetChatTitle

Represents the setChatTitle method.

SetInlineGameScore

Represents the setGameScore method for inline messages.

SetMessageGameScore

Represents the setGameScore method for chat messages.

SetPassportDataErrors

Represents the setPassportDataErrors method.

SetStickerPositionInSet

Represents the setStickerPositionInSet method.

StopInlineLocation

Represents the stopMessageLiveLocation method for inline messages.

StopMessageLocation

Represents the stopMessageLiveLocation method for chat messages.

StopPoll

Represents the stopPoll method.

UnbanChatMember

Represents the unbanChatMember method.

UnpinChatMessage

Represents the unpinChatMessage method.

UploadStickerFile

Represents the uploadStickerFile method.