// @generated by `cargo run -p xtask -- generate`. DO NOT EDIT.
//! Generated convenience methods on `Bot` for the pinned compatibility baseline.
#![allow(
clippy::too_many_arguments,
unused_mut,
rustdoc::bare_urls,
rustdoc::invalid_html_tags
)]
use super::Bot;
use crate::error::Result;
/// Generated Bot API convenience methods, excluding custom core shortcuts.
pub const GENERATED_BOT_SHORTCUT_COUNT: usize = 180;
impl Bot {
#[doc = "Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns True on success."]
pub async fn add_sticker_to_set(
&self,
user_id: i64,
name: impl Into<String>,
sticker: crate::types::InputSticker,
) -> Result<bool> {
self.execute(&crate::methods::AddStickerToSet::new(
user_id, name, sticker,
))
.await
}
#[doc = "Use this method to process a received chat join request query. Returns True on success."]
pub async fn answer_chat_join_request_query(
&self,
chat_join_request_query_id: impl Into<String>,
result: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::AnswerChatJoinRequestQuery::new(
chat_join_request_query_id,
result,
))
.await
}
#[doc = "Use this method to reply to a received guest message. On success, a SentGuestMessage object is returned."]
pub async fn answer_guest_query(
&self,
guest_query_id: impl Into<String>,
result: impl Into<crate::types::InlineQueryResultUnion>,
) -> Result<crate::types::SentGuestMessage> {
self.execute(&crate::methods::AnswerGuestQuery::new(
guest_query_id,
result,
))
.await
}
#[doc = "Use this method to send answers to an inline query. On success, True is returned."]
pub async fn answer_inline_query(
&self,
inline_query_id: impl Into<String>,
results: Vec<crate::types::InlineQueryResultUnion>,
) -> Result<bool> {
self.execute(&crate::methods::AnswerInlineQuery::new(
inline_query_id,
results,
))
.await
}
#[doc = "Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent."]
pub async fn answer_pre_checkout_query(
&self,
pre_checkout_query_id: impl Into<String>,
ok: bool,
) -> Result<bool> {
self.execute(&crate::methods::AnswerPreCheckoutQuery::new(
pre_checkout_query_id,
ok,
))
.await
}
#[doc = "If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned."]
pub async fn answer_shipping_query(
&self,
shipping_query_id: impl Into<String>,
ok: bool,
) -> Result<bool> {
self.execute(&crate::methods::AnswerShippingQuery::new(
shipping_query_id,
ok,
))
.await
}
#[doc = "Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned."]
pub async fn answer_web_app_query(
&self,
web_app_query_id: impl Into<String>,
result: impl Into<crate::types::InlineQueryResultUnion>,
) -> Result<crate::types::SentWebAppMessage> {
self.execute(&crate::methods::AnswerWebAppQuery::new(
web_app_query_id,
result,
))
.await
}
#[doc = "Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success."]
pub async fn approve_chat_join_request(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::ApproveChatJoinRequest::new(
chat_id, user_id,
))
.await
}
#[doc = "Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success."]
pub async fn approve_suggested_post(&self, chat_id: i64, message_id: i64) -> Result<bool> {
self.execute(&crate::methods::ApproveSuggestedPost::new(
chat_id, message_id,
))
.await
}
#[doc = "Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success."]
pub async fn ban_chat_member(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::BanChatMember::new(chat_id, user_id))
.await
}
#[doc = "Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success."]
pub async fn ban_chat_sender_chat(
&self,
chat_id: impl Into<crate::types::ChatId>,
sender_chat_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::BanChatSenderChat::new(
chat_id,
sender_chat_id,
))
.await
}
#[doc = "Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters."]
pub async fn close(&self) -> Result<bool> {
self.execute(&crate::methods::Close::new()).await
}
#[doc = "Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success."]
pub async fn close_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_thread_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::CloseForumTopic::new(
chat_id,
message_thread_id,
))
.await
}
#[doc = "Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success."]
pub async fn close_general_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::CloseGeneralForumTopic::new(chat_id))
.await
}
#[doc = "Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success."]
pub async fn convert_gift_to_stars(
&self,
business_connection_id: impl Into<String>,
owned_gift_id: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::ConvertGiftToStars::new(
business_connection_id,
owned_gift_id,
))
.await
}
#[doc = "Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success."]
pub async fn copy_message(
&self,
chat_id: impl Into<crate::types::ChatId>,
from_chat_id: impl Into<crate::types::ChatId>,
message_id: i64,
) -> Result<crate::types::MessageId> {
self.execute(&crate::methods::CopyMessage::new(
chat_id,
from_chat_id,
message_id,
))
.await
}
#[doc = "Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an Array of MessageId of the sent messages is returned."]
pub async fn copy_messages(
&self,
chat_id: impl Into<crate::types::ChatId>,
from_chat_id: impl Into<crate::types::ChatId>,
message_ids: Vec<i64>,
) -> Result<Vec<crate::types::MessageId>> {
self.execute(&crate::methods::CopyMessages::new(
chat_id,
from_chat_id,
message_ids,
))
.await
}
#[doc = "Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object."]
pub async fn create_chat_invite_link(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<crate::types::ChatInviteLink> {
self.execute(&crate::methods::CreateChatInviteLink::new(chat_id))
.await
}
#[doc = "Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object."]
pub async fn create_chat_subscription_invite_link(
&self,
chat_id: impl Into<crate::types::ChatId>,
subscription_period: i64,
subscription_price: i64,
) -> Result<crate::types::ChatInviteLink> {
self.execute(&crate::methods::CreateChatSubscriptionInviteLink::new(
chat_id,
subscription_period,
subscription_price,
))
.await
}
#[doc = "Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator right. Returns information about the created topic as a ForumTopic object."]
pub async fn create_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
name: impl Into<String>,
) -> Result<crate::types::ForumTopic> {
self.execute(&crate::methods::CreateForumTopic::new(chat_id, name))
.await
}
#[doc = "Use this method to create a link for an invoice. Returns the created invoice link as String on success."]
pub async fn create_invoice_link(
&self,
title: impl Into<String>,
description: impl Into<String>,
payload: impl Into<String>,
currency: impl Into<String>,
prices: Vec<crate::types::LabeledPrice>,
) -> Result<String> {
self.execute(&crate::methods::CreateInvoiceLink::new(
title,
description,
payload,
currency,
prices,
))
.await
}
#[doc = "Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success."]
pub async fn create_new_sticker_set(
&self,
user_id: i64,
name: impl Into<String>,
title: impl Into<String>,
stickers: Vec<crate::types::InputSticker>,
) -> Result<bool> {
self.execute(&crate::methods::CreateNewStickerSet::new(
user_id, name, title, stickers,
))
.await
}
#[doc = "Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success."]
pub async fn decline_chat_join_request(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::DeclineChatJoinRequest::new(
chat_id, user_id,
))
.await
}
#[doc = "Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success."]
pub async fn decline_suggested_post(&self, chat_id: i64, message_id: i64) -> Result<bool> {
self.execute(&crate::methods::DeclineSuggestedPost::new(
chat_id, message_id,
))
.await
}
#[doc = "Use this method to remove up to 10000 recent reactions in a group or a supergroup chat added by a given user or chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success."]
pub async fn delete_all_message_reactions(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::DeleteAllMessageReactions::new(chat_id))
.await
}
#[doc = "Delete messages on behalf of a business account. Requires the can_delete_sent_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success."]
pub async fn delete_business_messages(
&self,
business_connection_id: impl Into<String>,
message_ids: Vec<i64>,
) -> Result<bool> {
self.execute(&crate::methods::DeleteBusinessMessages::new(
business_connection_id,
message_ids,
))
.await
}
#[doc = "Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success."]
pub async fn delete_chat_photo(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::DeleteChatPhoto::new(chat_id))
.await
}
#[doc = "Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success."]
pub async fn delete_chat_sticker_set(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::DeleteChatStickerSet::new(chat_id))
.await
}
#[doc = "Use this method to delete an ephemeral message. Note that it is not guaranteed that the user will receive the message deletion event, especially if they are offline. Returns True on success."]
pub async fn delete_ephemeral_message(
&self,
chat_id: impl Into<crate::types::ChatId>,
receiver_user_id: i64,
ephemeral_message_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::DeleteEphemeralMessage::new(
chat_id,
receiver_user_id,
ephemeral_message_id,
))
.await
}
#[doc = "Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success."]
pub async fn delete_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_thread_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::DeleteForumTopic::new(
chat_id,
message_thread_id,
))
.await
}
#[doc = "Use this method to delete a message, including service messages, with the following limitations:"]
pub async fn delete_message(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::DeleteMessage::new(chat_id, message_id))
.await
}
#[doc = "Use this method to remove a reaction from a message in a group or a supergroup chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success."]
pub async fn delete_message_reaction(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::DeleteMessageReaction::new(
chat_id, message_id,
))
.await
}
#[doc = "Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped. Returns True on success."]
pub async fn delete_messages(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_ids: Vec<i64>,
) -> Result<bool> {
self.execute(&crate::methods::DeleteMessages::new(chat_id, message_ids))
.await
}
#[doc = "Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success."]
pub async fn delete_my_commands(
&self,
method: crate::methods::DeleteMyCommands,
) -> Result<bool> {
self.execute(&method).await
}
#[doc = "Use this method to delete a sticker from a set created by the bot. Returns True on success."]
pub async fn delete_sticker_from_set(&self, sticker: impl Into<String>) -> Result<bool> {
self.execute(&crate::methods::DeleteStickerFromSet::new(sticker))
.await
}
#[doc = "Use this method to delete a sticker set that was created by the bot. Returns True on success."]
pub async fn delete_sticker_set(&self, name: impl Into<String>) -> Result<bool> {
self.execute(&crate::methods::DeleteStickerSet::new(name))
.await
}
#[doc = "Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success."]
pub async fn delete_story(
&self,
business_connection_id: impl Into<String>,
story_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::DeleteStory::new(
business_connection_id,
story_id,
))
.await
}
#[doc = "Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success."]
pub async fn delete_webhook(&self, method: crate::methods::DeleteWebhook) -> Result<bool> {
self.execute(&method).await
}
#[doc = "Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object."]
pub async fn edit_chat_invite_link(
&self,
chat_id: impl Into<crate::types::ChatId>,
invite_link: impl Into<String>,
) -> Result<crate::types::ChatInviteLink> {
self.execute(&crate::methods::EditChatInviteLink::new(
chat_id,
invite_link,
))
.await
}
#[doc = "Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object."]
pub async fn edit_chat_subscription_invite_link(
&self,
chat_id: impl Into<crate::types::ChatId>,
invite_link: impl Into<String>,
) -> Result<crate::types::ChatInviteLink> {
self.execute(&crate::methods::EditChatSubscriptionInviteLink::new(
chat_id,
invite_link,
))
.await
}
#[doc = "Use this method to edit the caption of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned."]
pub async fn edit_ephemeral_message_caption(
&self,
chat_id: impl Into<crate::types::ChatId>,
receiver_user_id: i64,
ephemeral_message_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::EditEphemeralMessageCaption::new(
chat_id,
receiver_user_id,
ephemeral_message_id,
))
.await
}
#[doc = "Use this method to edit the media of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned."]
pub async fn edit_ephemeral_message_media(
&self,
chat_id: impl Into<crate::types::ChatId>,
receiver_user_id: i64,
ephemeral_message_id: i64,
media: impl Into<crate::types::InputMediaUnion>,
) -> Result<bool> {
self.execute(&crate::methods::EditEphemeralMessageMedia::new(
chat_id,
receiver_user_id,
ephemeral_message_id,
media,
))
.await
}
#[doc = "Use this method to edit only the reply markup of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned."]
pub async fn edit_ephemeral_message_reply_markup(
&self,
chat_id: impl Into<crate::types::ChatId>,
receiver_user_id: i64,
ephemeral_message_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::EditEphemeralMessageReplyMarkup::new(
chat_id,
receiver_user_id,
ephemeral_message_id,
))
.await
}
#[doc = "Use this method to edit an ephemeral text message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned."]
pub async fn edit_ephemeral_message_text(
&self,
chat_id: impl Into<crate::types::ChatId>,
receiver_user_id: i64,
ephemeral_message_id: i64,
text: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::EditEphemeralMessageText::new(
chat_id,
receiver_user_id,
ephemeral_message_id,
text,
))
.await
}
#[doc = "Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success."]
pub async fn edit_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_thread_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::EditForumTopic::new(
chat_id,
message_thread_id,
))
.await
}
#[doc = "Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success."]
pub async fn edit_general_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
name: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::EditGeneralForumTopic::new(chat_id, name))
.await
}
#[doc = "Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent."]
pub async fn edit_message_caption(
&self,
method: crate::methods::EditMessageCaption,
) -> Result<crate::methods::MessageOrBool> {
self.execute(&method).await
}
#[doc = "Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned."]
pub async fn edit_message_checklist(
&self,
business_connection_id: impl Into<String>,
chat_id: impl Into<crate::types::ChatId>,
message_id: i64,
checklist: crate::types::InputChecklist,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::EditMessageChecklist::new(
business_connection_id,
chat_id,
message_id,
checklist,
))
.await
}
#[doc = "Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned."]
pub async fn edit_message_live_location(
&self,
latitude: f64,
longitude: f64,
) -> Result<crate::methods::MessageOrBool> {
self.execute(&crate::methods::EditMessageLiveLocation::new(
latitude, longitude,
))
.await
}
#[doc = "Use this method to edit animation, audio, document, live photo, photo, or video messages, or to replace a text or a rich message with a media. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo, a live photo, or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent."]
pub async fn edit_message_media(
&self,
media: impl Into<crate::types::InputMediaUnion>,
) -> Result<crate::methods::MessageOrBool> {
self.execute(&crate::methods::EditMessageMedia::new(media))
.await
}
#[doc = "Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent."]
pub async fn edit_message_reply_markup(
&self,
method: crate::methods::EditMessageReplyMarkup,
) -> Result<crate::methods::MessageOrBool> {
self.execute(&method).await
}
#[doc = "Use this method to edit text, rich and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent."]
pub async fn edit_message_text(
&self,
method: crate::methods::EditMessageText,
) -> Result<crate::methods::MessageOrBool> {
self.execute(&method).await
}
#[doc = "Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success."]
pub async fn edit_story(
&self,
business_connection_id: impl Into<String>,
story_id: i64,
content: impl Into<crate::types::InputStoryContentUnion>,
) -> Result<crate::types::Story> {
self.execute(&crate::methods::EditStory::new(
business_connection_id,
story_id,
content,
))
.await
}
#[doc = "Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success."]
pub async fn edit_user_star_subscription(
&self,
user_id: i64,
telegram_payment_charge_id: impl Into<String>,
is_canceled: bool,
) -> Result<bool> {
self.execute(&crate::methods::EditUserStarSubscription::new(
user_id,
telegram_payment_charge_id,
is_canceled,
))
.await
}
#[doc = "Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success."]
pub async fn export_chat_invite_link(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<String> {
self.execute(&crate::methods::ExportChatInviteLink::new(chat_id))
.await
}
#[doc = "Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned."]
pub async fn forward_message(
&self,
chat_id: impl Into<crate::types::ChatId>,
from_chat_id: impl Into<crate::types::ChatId>,
message_id: i64,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::ForwardMessage::new(
chat_id,
from_chat_id,
message_id,
))
.await
}
#[doc = "Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an Array of MessageId of the sent messages is returned."]
pub async fn forward_messages(
&self,
chat_id: impl Into<crate::types::ChatId>,
from_chat_id: impl Into<crate::types::ChatId>,
message_ids: Vec<i64>,
) -> Result<Vec<crate::types::MessageId>> {
self.execute(&crate::methods::ForwardMessages::new(
chat_id,
from_chat_id,
message_ids,
))
.await
}
#[doc = "Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a Gifts object."]
pub async fn get_available_gifts(&self) -> Result<crate::types::Gifts> {
self.execute(&crate::methods::GetAvailableGifts::new())
.await
}
#[doc = "Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success."]
pub async fn get_business_account_gifts(
&self,
business_connection_id: impl Into<String>,
) -> Result<crate::types::OwnedGifts> {
self.execute(&crate::methods::GetBusinessAccountGifts::new(
business_connection_id,
))
.await
}
#[doc = "Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success."]
pub async fn get_business_account_star_balance(
&self,
business_connection_id: impl Into<String>,
) -> Result<crate::types::StarAmount> {
self.execute(&crate::methods::GetBusinessAccountStarBalance::new(
business_connection_id,
))
.await
}
#[doc = "Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success."]
pub async fn get_business_connection(
&self,
business_connection_id: impl Into<String>,
) -> Result<crate::types::BusinessConnection> {
self.execute(&crate::methods::GetBusinessConnection::new(
business_connection_id,
))
.await
}
#[doc = "Use this method to get up-to-date information about the chat. Returns a ChatFullInfo object on success."]
pub async fn get_chat(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<crate::types::ChatFullInfo> {
self.execute(&crate::methods::GetChat::new(chat_id)).await
}
#[doc = "Use this method to get a list of administrators in a chat. Returns an Array of ChatMember objects."]
pub async fn get_chat_administrators(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<Vec<crate::types::ResultChatMemberUnion>> {
self.execute(&crate::methods::GetChatAdministrators::new(chat_id))
.await
}
#[doc = "Returns the gifts owned by a chat. Returns OwnedGifts on success."]
pub async fn get_chat_gifts(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<crate::types::OwnedGifts> {
self.execute(&crate::methods::GetChatGifts::new(chat_id))
.await
}
#[doc = "Use this method to get information about a member of a chat. The method is only guaranteed to work for other users if the bot is an administrator in the chat. Returns a ChatMember object on success."]
pub async fn get_chat_member(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
) -> Result<crate::types::ResultChatMemberUnion> {
self.execute(&crate::methods::GetChatMember::new(chat_id, user_id))
.await
}
#[doc = "Use this method to get the number of members in a chat. Returns Integer on success."]
pub async fn get_chat_member_count(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<i64> {
self.execute(&crate::methods::GetChatMemberCount::new(chat_id))
.await
}
#[doc = "Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success."]
pub async fn get_chat_menu_button(
&self,
method: crate::methods::GetChatMenuButton,
) -> Result<crate::types::ResultMenuButtonUnion> {
self.execute(&method).await
}
#[doc = "Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects."]
pub async fn get_custom_emoji_stickers(
&self,
custom_emoji_ids: Vec<String>,
) -> Result<Vec<crate::types::Sticker>> {
self.execute(&crate::methods::GetCustomEmojiStickers::new(
custom_emoji_ids,
))
.await
}
#[doc = "Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of Sticker objects."]
pub async fn get_forum_topic_icon_stickers(&self) -> Result<Vec<crate::types::Sticker>> {
self.execute(&crate::methods::GetForumTopicIconStickers::new())
.await
}
#[doc = "Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects."]
pub async fn get_game_high_scores(
&self,
user_id: i64,
) -> Result<Vec<crate::types::GameHighScore>> {
self.execute(&crate::methods::GetGameHighScores::new(user_id))
.await
}
#[doc = "Use this method to get the access settings of a managed bot. Returns a BotAccessSettings object on success."]
pub async fn get_managed_bot_access_settings(
&self,
user_id: i64,
) -> Result<crate::types::BotAccessSettings> {
self.execute(&crate::methods::GetManagedBotAccessSettings::new(user_id))
.await
}
#[doc = "Use this method to get the token of a managed bot. Returns the token as String on success."]
pub async fn get_managed_bot_token(&self, user_id: i64) -> Result<String> {
self.execute(&crate::methods::GetManagedBotToken::new(user_id))
.await
}
#[doc = "Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned."]
pub async fn get_my_commands(
&self,
method: crate::methods::GetMyCommands,
) -> Result<Vec<crate::types::BotCommand>> {
self.execute(&method).await
}
#[doc = "Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success."]
pub async fn get_my_default_administrator_rights(
&self,
method: crate::methods::GetMyDefaultAdministratorRights,
) -> Result<crate::types::ChatAdministratorRights> {
self.execute(&method).await
}
#[doc = "Use this method to get the current bot description for the given user language. Returns BotDescription on success."]
pub async fn get_my_description(
&self,
method: crate::methods::GetMyDescription,
) -> Result<crate::types::BotDescription> {
self.execute(&method).await
}
#[doc = "Use this method to get the current bot name for the given user language. Returns BotName on success."]
pub async fn get_my_name(
&self,
method: crate::methods::GetMyName,
) -> Result<crate::types::BotName> {
self.execute(&method).await
}
#[doc = "Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success."]
pub async fn get_my_short_description(
&self,
method: crate::methods::GetMyShortDescription,
) -> Result<crate::types::BotShortDescription> {
self.execute(&method).await
}
#[doc = "A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object."]
pub async fn get_my_star_balance(&self) -> Result<crate::types::StarAmount> {
self.execute(&crate::methods::GetMyStarBalance::new()).await
}
#[doc = "Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object."]
pub async fn get_star_transactions(
&self,
method: crate::methods::GetStarTransactions,
) -> Result<crate::types::StarTransactions> {
self.execute(&method).await
}
#[doc = "Use this method to get a sticker set. On success, a StickerSet object is returned."]
pub async fn get_sticker_set(
&self,
name: impl Into<String>,
) -> Result<crate::types::StickerSet> {
self.execute(&crate::methods::GetStickerSet::new(name))
.await
}
#[doc = "Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object."]
pub async fn get_user_chat_boosts(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
) -> Result<crate::types::UserChatBoosts> {
self.execute(&crate::methods::GetUserChatBoosts::new(chat_id, user_id))
.await
}
#[doc = "Returns the gifts owned and hosted by a user. Returns OwnedGifts on success."]
pub async fn get_user_gifts(&self, user_id: i64) -> Result<crate::types::OwnedGifts> {
self.execute(&crate::methods::GetUserGifts::new(user_id))
.await
}
#[doc = "Use this method to get the last messages from the personal chat (i.e., the chat currently added to their profile) of a given user. On success, an Array of Message objects is returned."]
pub async fn get_user_personal_chat_messages(
&self,
user_id: i64,
limit: i64,
) -> Result<Vec<crate::types::Message>> {
self.execute(&crate::methods::GetUserPersonalChatMessages::new(
user_id, limit,
))
.await
}
#[doc = "Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object."]
pub async fn get_user_profile_audios(
&self,
user_id: i64,
) -> Result<crate::types::UserProfileAudios> {
self.execute(&crate::methods::GetUserProfileAudios::new(user_id))
.await
}
#[doc = "Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object."]
pub async fn get_user_profile_photos(
&self,
user_id: i64,
) -> Result<crate::types::UserProfilePhotos> {
self.execute(&crate::methods::GetUserProfilePhotos::new(user_id))
.await
}
#[doc = "Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty."]
pub async fn get_webhook_info(&self) -> Result<crate::types::WebhookInfo> {
self.execute(&crate::methods::GetWebhookInfo::new()).await
}
#[doc = "Gifts a Telegram Premium subscription to the given user. Returns True on success."]
pub async fn gift_premium_subscription(
&self,
user_id: i64,
month_count: i64,
star_count: i64,
) -> Result<bool> {
self.execute(&crate::methods::GiftPremiumSubscription::new(
user_id,
month_count,
star_count,
))
.await
}
#[doc = "Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success."]
pub async fn hide_general_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::HideGeneralForumTopic::new(chat_id))
.await
}
#[doc = "Use this method for your bot to leave a group, supergroup or channel. Returns True on success."]
pub async fn leave_chat(&self, chat_id: impl Into<crate::types::ChatId>) -> Result<bool> {
self.execute(&crate::methods::LeaveChat::new(chat_id)).await
}
#[doc = "Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters."]
pub async fn log_out(&self) -> Result<bool> {
self.execute(&crate::methods::LogOut::new()).await
}
#[doc = "Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success."]
pub async fn pin_chat_message(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::PinChatMessage::new(chat_id, message_id))
.await
}
#[doc = "Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success."]
pub async fn post_story(
&self,
business_connection_id: impl Into<String>,
content: impl Into<crate::types::InputStoryContentUnion>,
active_period: i64,
) -> Result<crate::types::Story> {
self.execute(&crate::methods::PostStory::new(
business_connection_id,
content,
active_period,
))
.await
}
#[doc = "Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success."]
pub async fn promote_chat_member(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::PromoteChatMember::new(chat_id, user_id))
.await
}
#[doc = "Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success."]
pub async fn read_business_message(
&self,
business_connection_id: impl Into<String>,
chat_id: i64,
message_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::ReadBusinessMessage::new(
business_connection_id,
chat_id,
message_id,
))
.await
}
#[doc = "Refunds a successful payment in Telegram Stars. Returns True on success."]
pub async fn refund_star_payment(
&self,
user_id: i64,
telegram_payment_charge_id: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::RefundStarPayment::new(
user_id,
telegram_payment_charge_id,
))
.await
}
#[doc = "Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success."]
pub async fn remove_business_account_profile_photo(
&self,
business_connection_id: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::RemoveBusinessAccountProfilePhoto::new(
business_connection_id,
))
.await
}
#[doc = "Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success."]
pub async fn remove_chat_verification(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::RemoveChatVerification::new(chat_id))
.await
}
#[doc = "Removes the profile photo of the bot. Requires no parameters. Returns True on success."]
pub async fn remove_my_profile_photo(&self) -> Result<bool> {
self.execute(&crate::methods::RemoveMyProfilePhoto::new())
.await
}
#[doc = "Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success."]
pub async fn remove_user_verification(&self, user_id: i64) -> Result<bool> {
self.execute(&crate::methods::RemoveUserVerification::new(user_id))
.await
}
#[doc = "Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success."]
pub async fn reopen_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_thread_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::ReopenForumTopic::new(
chat_id,
message_thread_id,
))
.await
}
#[doc = "Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success."]
pub async fn reopen_general_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::ReopenGeneralForumTopic::new(chat_id))
.await
}
#[doc = "Use this method to revoke the current token of a managed bot and generate a new one. Returns the new token as String on success."]
pub async fn replace_managed_bot_token(&self, user_id: i64) -> Result<String> {
self.execute(&crate::methods::ReplaceManagedBotToken::new(user_id))
.await
}
#[doc = "Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success."]
pub async fn replace_sticker_in_set(
&self,
user_id: i64,
name: impl Into<String>,
old_sticker: impl Into<String>,
sticker: crate::types::InputSticker,
) -> Result<bool> {
self.execute(&crate::methods::ReplaceStickerInSet::new(
user_id,
name,
old_sticker,
sticker,
))
.await
}
#[doc = "Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success."]
pub async fn repost_story(
&self,
business_connection_id: impl Into<String>,
from_chat_id: i64,
from_story_id: i64,
active_period: i64,
) -> Result<crate::types::Story> {
self.execute(&crate::methods::RepostStory::new(
business_connection_id,
from_chat_id,
from_story_id,
active_period,
))
.await
}
#[doc = "Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success."]
pub async fn restrict_chat_member(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
permissions: crate::types::ChatPermissions,
) -> Result<bool> {
self.execute(&crate::methods::RestrictChatMember::new(
chat_id,
user_id,
permissions,
))
.await
}
#[doc = "Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object."]
pub async fn revoke_chat_invite_link(
&self,
chat_id: impl Into<crate::types::ChatId>,
invite_link: impl Into<String>,
) -> Result<crate::types::ChatInviteLink> {
self.execute(&crate::methods::RevokeChatInviteLink::new(
chat_id,
invite_link,
))
.await
}
#[doc = "Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object."]
pub async fn save_prepared_inline_message(
&self,
user_id: i64,
result: impl Into<crate::types::InlineQueryResultUnion>,
) -> Result<crate::types::PreparedInlineMessage> {
self.execute(&crate::methods::SavePreparedInlineMessage::new(
user_id, result,
))
.await
}
#[doc = "Stores a keyboard button that can be used by a user within a Mini App. Returns a PreparedKeyboardButton object."]
pub async fn save_prepared_keyboard_button(
&self,
user_id: i64,
button: crate::types::KeyboardButton,
) -> Result<crate::types::PreparedKeyboardButton> {
self.execute(&crate::methods::SavePreparedKeyboardButton::new(
user_id, button,
))
.await
}
#[doc = "Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future."]
pub async fn send_animation(
&self,
chat_id: impl Into<crate::types::ChatId>,
animation: impl Into<crate::types::InputFile>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendAnimation::new(chat_id, animation))
.await
}
#[doc = "Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future."]
pub async fn send_audio(
&self,
chat_id: impl Into<crate::types::ChatId>,
audio: impl Into<crate::types::InputFile>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendAudio::new(chat_id, audio))
.await
}
#[doc = "Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success."]
pub async fn send_chat_action(
&self,
chat_id: impl Into<crate::types::ChatId>,
action: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SendChatAction::new(chat_id, action))
.await
}
#[doc = "Use this method to process a received chat join request query by showing a Mini App to the user before deciding the outcome. Call answerChatJoinRequestQuery to resolve the join request query based on the user interaction with the Mini App. Returns True on success."]
pub async fn send_chat_join_request_web_app(
&self,
chat_join_request_query_id: impl Into<String>,
web_app_url: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SendChatJoinRequestWebApp::new(
chat_join_request_query_id,
web_app_url,
))
.await
}
#[doc = "Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned."]
pub async fn send_checklist(
&self,
business_connection_id: impl Into<String>,
chat_id: impl Into<crate::types::ChatId>,
checklist: crate::types::InputChecklist,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendChecklist::new(
business_connection_id,
chat_id,
checklist,
))
.await
}
#[doc = "Use this method to send phone contacts. On success, the sent Message is returned."]
pub async fn send_contact(
&self,
chat_id: impl Into<crate::types::ChatId>,
phone_number: impl Into<String>,
first_name: impl Into<String>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendContact::new(
chat_id,
phone_number,
first_name,
))
.await
}
#[doc = "Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned."]
pub async fn send_dice(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendDice::new(chat_id)).await
}
#[doc = "Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future."]
pub async fn send_document(
&self,
chat_id: impl Into<crate::types::ChatId>,
document: impl Into<crate::types::InputFile>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendDocument::new(chat_id, document))
.await
}
#[doc = "Use this method to send a game. On success, the sent Message is returned."]
pub async fn send_game(
&self,
chat_id: impl Into<crate::types::ChatId>,
game_short_name: impl Into<String>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendGame::new(chat_id, game_short_name))
.await
}
#[doc = "Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success."]
pub async fn send_gift(&self, gift_id: impl Into<String>) -> Result<bool> {
self.execute(&crate::methods::SendGift::new(gift_id)).await
}
#[doc = "Use this method to send invoices. On success, the sent Message is returned."]
pub async fn send_invoice(
&self,
chat_id: impl Into<crate::types::ChatId>,
title: impl Into<String>,
description: impl Into<String>,
payload: impl Into<String>,
currency: impl Into<String>,
prices: Vec<crate::types::LabeledPrice>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendInvoice::new(
chat_id,
title,
description,
payload,
currency,
prices,
))
.await
}
#[doc = "Use this method to send live photos. On success, the sent Message is returned."]
pub async fn send_live_photo(
&self,
chat_id: impl Into<crate::types::ChatId>,
live_photo: impl Into<crate::types::InputFile>,
photo: impl Into<crate::types::InputFile>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendLivePhoto::new(
chat_id, live_photo, photo,
))
.await
}
#[doc = "Use this method to send point on the map. On success, the sent Message is returned."]
pub async fn send_location(
&self,
chat_id: impl Into<crate::types::ChatId>,
latitude: f64,
longitude: f64,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendLocation::new(
chat_id, latitude, longitude,
))
.await
}
#[doc = "Use this method to send a group of photos, live photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an Array of Message objects that were sent is returned."]
pub async fn send_media_group(
&self,
chat_id: impl Into<crate::types::ChatId>,
media: Vec<crate::types::MediaUnion>,
) -> Result<Vec<crate::types::Message>> {
self.execute(&crate::methods::SendMediaGroup::new(chat_id, media))
.await
}
#[doc = "Use this method to stream a partial message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendMessage with the complete message to persist it in the user's chat. Returns True on success."]
pub async fn send_message_draft(&self, chat_id: i64, draft_id: i64) -> Result<bool> {
self.execute(&crate::methods::SendMessageDraft::new(chat_id, draft_id))
.await
}
#[doc = "Use this method to send paid media. On success, the sent Message is returned."]
pub async fn send_paid_media(
&self,
chat_id: impl Into<crate::types::ChatId>,
star_count: i64,
media: Vec<crate::types::InputPaidMediaUnion>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendPaidMedia::new(
chat_id, star_count, media,
))
.await
}
#[doc = "Use this method to send photos. On success, the sent Message is returned."]
pub async fn send_photo(
&self,
chat_id: impl Into<crate::types::ChatId>,
photo: impl Into<crate::types::InputFile>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendPhoto::new(chat_id, photo))
.await
}
#[doc = "Use this method to send a native poll. On success, the sent Message is returned."]
pub async fn send_poll(
&self,
chat_id: impl Into<crate::types::ChatId>,
question: impl Into<String>,
options: Vec<crate::types::InputPollOptionUnion>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendPoll::new(chat_id, question, options))
.await
}
#[doc = "Use this method to send rich messages. If the message contains a block with a media element, then the bot must have the right to send the media to the chat. On success, the sent Message is returned."]
pub async fn send_rich_message(
&self,
chat_id: impl Into<crate::types::ChatId>,
rich_message: crate::types::InputRichMessage,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendRichMessage::new(chat_id, rich_message))
.await
}
#[doc = "Use this method to stream a partial rich message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendRichMessage with the complete message to persist it in the user's chat. Returns True on success."]
pub async fn send_rich_message_draft(
&self,
chat_id: i64,
draft_id: i64,
rich_message: crate::types::InputRichMessage,
) -> Result<bool> {
self.execute(&crate::methods::SendRichMessageDraft::new(
chat_id,
draft_id,
rich_message,
))
.await
}
#[doc = "Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned."]
pub async fn send_sticker(
&self,
chat_id: impl Into<crate::types::ChatId>,
sticker: impl Into<crate::types::InputFile>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendSticker::new(chat_id, sticker))
.await
}
#[doc = "Use this method to send information about a venue. On success, the sent Message is returned."]
pub async fn send_venue(
&self,
chat_id: impl Into<crate::types::ChatId>,
latitude: f64,
longitude: f64,
title: impl Into<String>,
address: impl Into<String>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendVenue::new(
chat_id, latitude, longitude, title, address,
))
.await
}
#[doc = "Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future."]
pub async fn send_video(
&self,
chat_id: impl Into<crate::types::ChatId>,
video: impl Into<crate::types::InputFile>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendVideo::new(chat_id, video))
.await
}
#[doc = "As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned."]
pub async fn send_video_note(
&self,
chat_id: impl Into<crate::types::ChatId>,
video_note: impl Into<crate::types::InputFile>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendVideoNote::new(chat_id, video_note))
.await
}
#[doc = "Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future."]
pub async fn send_voice(
&self,
chat_id: impl Into<crate::types::ChatId>,
voice: impl Into<crate::types::InputFile>,
) -> Result<crate::types::Message> {
self.execute(&crate::methods::SendVoice::new(chat_id, voice))
.await
}
#[doc = "Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success."]
pub async fn set_business_account_bio(
&self,
business_connection_id: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetBusinessAccountBio::new(
business_connection_id,
))
.await
}
#[doc = "Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success."]
pub async fn set_business_account_gift_settings(
&self,
business_connection_id: impl Into<String>,
show_gift_button: bool,
accepted_gift_types: crate::types::AcceptedGiftTypes,
) -> Result<bool> {
self.execute(&crate::methods::SetBusinessAccountGiftSettings::new(
business_connection_id,
show_gift_button,
accepted_gift_types,
))
.await
}
#[doc = "Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success."]
pub async fn set_business_account_name(
&self,
business_connection_id: impl Into<String>,
first_name: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetBusinessAccountName::new(
business_connection_id,
first_name,
))
.await
}
#[doc = "Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success."]
pub async fn set_business_account_profile_photo(
&self,
business_connection_id: impl Into<String>,
photo: impl Into<crate::types::InputProfilePhotoUnion>,
) -> Result<bool> {
self.execute(&crate::methods::SetBusinessAccountProfilePhoto::new(
business_connection_id,
photo,
))
.await
}
#[doc = "Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success."]
pub async fn set_business_account_username(
&self,
business_connection_id: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetBusinessAccountUsername::new(
business_connection_id,
))
.await
}
#[doc = "Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success."]
pub async fn set_chat_administrator_custom_title(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
custom_title: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetChatAdministratorCustomTitle::new(
chat_id,
user_id,
custom_title,
))
.await
}
#[doc = "Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success."]
pub async fn set_chat_description(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::SetChatDescription::new(chat_id))
.await
}
#[doc = "Use this method to set a tag for a regular member in a group or a supergroup. The bot must be an administrator in the chat for this to work and must have the can_manage_tags administrator right. Returns True on success."]
pub async fn set_chat_member_tag(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::SetChatMemberTag::new(chat_id, user_id))
.await
}
#[doc = "Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success."]
pub async fn set_chat_menu_button(
&self,
method: crate::methods::SetChatMenuButton,
) -> Result<bool> {
self.execute(&method).await
}
#[doc = "Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success."]
pub async fn set_chat_permissions(
&self,
chat_id: impl Into<crate::types::ChatId>,
permissions: crate::types::ChatPermissions,
) -> Result<bool> {
self.execute(&crate::methods::SetChatPermissions::new(
chat_id,
permissions,
))
.await
}
#[doc = "Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success."]
pub async fn set_chat_photo(
&self,
chat_id: impl Into<crate::types::ChatId>,
photo: impl Into<crate::types::InputFile>,
) -> Result<bool> {
self.execute(&crate::methods::SetChatPhoto::new(chat_id, photo))
.await
}
#[doc = "Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success."]
pub async fn set_chat_sticker_set(
&self,
chat_id: impl Into<crate::types::ChatId>,
sticker_set_name: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetChatStickerSet::new(
chat_id,
sticker_set_name,
))
.await
}
#[doc = "Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success."]
pub async fn set_chat_title(
&self,
chat_id: impl Into<crate::types::ChatId>,
title: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetChatTitle::new(chat_id, title))
.await
}
#[doc = "Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success."]
pub async fn set_custom_emoji_sticker_set_thumbnail(
&self,
name: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetCustomEmojiStickerSetThumbnail::new(
name,
))
.await
}
#[doc = "Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False."]
pub async fn set_game_score(
&self,
user_id: i64,
score: i64,
) -> Result<crate::methods::MessageOrBool> {
self.execute(&crate::methods::SetGameScore::new(user_id, score))
.await
}
#[doc = "Use this method to change the access settings of a managed bot. Returns True on success."]
pub async fn set_managed_bot_access_settings(
&self,
user_id: i64,
is_access_restricted: bool,
) -> Result<bool> {
self.execute(&crate::methods::SetManagedBotAccessSettings::new(
user_id,
is_access_restricted,
))
.await
}
#[doc = "Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success."]
pub async fn set_message_reaction(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::SetMessageReaction::new(
chat_id, message_id,
))
.await
}
#[doc = "Use this method to change the list of the bot's commands. See this manual for more details about bot commands. Returns True on success."]
pub async fn set_my_commands(&self, commands: Vec<crate::types::BotCommand>) -> Result<bool> {
self.execute(&crate::methods::SetMyCommands::new(commands))
.await
}
#[doc = "Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success."]
pub async fn set_my_default_administrator_rights(
&self,
method: crate::methods::SetMyDefaultAdministratorRights,
) -> Result<bool> {
self.execute(&method).await
}
#[doc = "Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success."]
pub async fn set_my_description(
&self,
method: crate::methods::SetMyDescription,
) -> Result<bool> {
self.execute(&method).await
}
#[doc = "Use this method to change the bot's name. Returns True on success."]
pub async fn set_my_name(&self, method: crate::methods::SetMyName) -> Result<bool> {
self.execute(&method).await
}
#[doc = "Changes the profile photo of the bot. Returns True on success."]
pub async fn set_my_profile_photo(
&self,
photo: impl Into<crate::types::InputProfilePhotoUnion>,
) -> Result<bool> {
self.execute(&crate::methods::SetMyProfilePhoto::new(photo))
.await
}
#[doc = "Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success."]
pub async fn set_my_short_description(
&self,
method: crate::methods::SetMyShortDescription,
) -> Result<bool> {
self.execute(&method).await
}
#[doc = "Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success."]
pub async fn set_passport_data_errors(
&self,
user_id: i64,
errors: Vec<crate::types::PassportElementErrorUnion>,
) -> Result<bool> {
self.execute(&crate::methods::SetPassportDataErrors::new(user_id, errors))
.await
}
#[doc = "Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success."]
pub async fn set_sticker_emoji_list(
&self,
sticker: impl Into<String>,
emoji_list: Vec<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetStickerEmojiList::new(
sticker, emoji_list,
))
.await
}
#[doc = "Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success."]
pub async fn set_sticker_keywords(&self, sticker: impl Into<String>) -> Result<bool> {
self.execute(&crate::methods::SetStickerKeywords::new(sticker))
.await
}
#[doc = "Use this method to change the mask position of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success."]
pub async fn set_sticker_mask_position(&self, sticker: impl Into<String>) -> Result<bool> {
self.execute(&crate::methods::SetStickerMaskPosition::new(sticker))
.await
}
#[doc = "Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success."]
pub async fn set_sticker_position_in_set(
&self,
sticker: impl Into<String>,
position: i64,
) -> Result<bool> {
self.execute(&crate::methods::SetStickerPositionInSet::new(
sticker, position,
))
.await
}
#[doc = "Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success."]
pub async fn set_sticker_set_thumbnail(
&self,
name: impl Into<String>,
user_id: i64,
format: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetStickerSetThumbnail::new(
name, user_id, format,
))
.await
}
#[doc = "Use this method to set the title of a created sticker set. Returns True on success."]
pub async fn set_sticker_set_title(
&self,
name: impl Into<String>,
title: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::SetStickerSetTitle::new(name, title))
.await
}
#[doc = "Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success."]
pub async fn set_user_emoji_status(&self, user_id: i64) -> Result<bool> {
self.execute(&crate::methods::SetUserEmojiStatus::new(user_id))
.await
}
#[doc = "Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success."]
pub async fn set_webhook(&self, url: impl Into<String>) -> Result<bool> {
self.execute(&crate::methods::SetWebhook::new(url)).await
}
#[doc = "Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned."]
pub async fn stop_message_live_location(
&self,
method: crate::methods::StopMessageLiveLocation,
) -> Result<crate::methods::MessageOrBool> {
self.execute(&method).await
}
#[doc = "Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned."]
pub async fn stop_poll(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_id: i64,
) -> Result<crate::types::Poll> {
self.execute(&crate::methods::StopPoll::new(chat_id, message_id))
.await
}
#[doc = "Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success."]
pub async fn transfer_business_account_stars(
&self,
business_connection_id: impl Into<String>,
star_count: i64,
) -> Result<bool> {
self.execute(&crate::methods::TransferBusinessAccountStars::new(
business_connection_id,
star_count,
))
.await
}
#[doc = "Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success."]
pub async fn transfer_gift(
&self,
business_connection_id: impl Into<String>,
owned_gift_id: impl Into<String>,
new_owner_chat_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::TransferGift::new(
business_connection_id,
owned_gift_id,
new_owner_chat_id,
))
.await
}
#[doc = "Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success."]
pub async fn unban_chat_member(
&self,
chat_id: impl Into<crate::types::ChatId>,
user_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::UnbanChatMember::new(chat_id, user_id))
.await
}
#[doc = "Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success."]
pub async fn unban_chat_sender_chat(
&self,
chat_id: impl Into<crate::types::ChatId>,
sender_chat_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::UnbanChatSenderChat::new(
chat_id,
sender_chat_id,
))
.await
}
#[doc = "Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success."]
pub async fn unhide_general_forum_topic(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::UnhideGeneralForumTopic::new(chat_id))
.await
}
#[doc = "Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin all pinned messages in groups and channels respectively. Returns True on success."]
pub async fn unpin_all_chat_messages(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::UnpinAllChatMessages::new(chat_id))
.await
}
#[doc = "Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success."]
pub async fn unpin_all_forum_topic_messages(
&self,
chat_id: impl Into<crate::types::ChatId>,
message_thread_id: i64,
) -> Result<bool> {
self.execute(&crate::methods::UnpinAllForumTopicMessages::new(
chat_id,
message_thread_id,
))
.await
}
#[doc = "Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success."]
pub async fn unpin_all_general_forum_topic_messages(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::UnpinAllGeneralForumTopicMessages::new(
chat_id,
))
.await
}
#[doc = "Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively. Returns True on success."]
pub async fn unpin_chat_message(
&self,
chat_id: impl Into<crate::types::ChatId>,
) -> Result<bool> {
self.execute(&crate::methods::UnpinChatMessage::new(chat_id))
.await
}
#[doc = "Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success."]
pub async fn upgrade_gift(
&self,
business_connection_id: impl Into<String>,
owned_gift_id: impl Into<String>,
) -> Result<bool> {
self.execute(&crate::methods::UpgradeGift::new(
business_connection_id,
owned_gift_id,
))
.await
}
#[doc = "Use this method to upload a file with a sticker for later use in the createNewStickerSet, addStickerToSet, or replaceStickerInSet methods (the file can be used multiple times). Returns the uploaded File on success."]
pub async fn upload_sticker_file(
&self,
user_id: i64,
sticker: impl Into<crate::types::InputFile>,
sticker_format: impl Into<String>,
) -> Result<crate::types::File> {
self.execute(&crate::methods::UploadStickerFile::new(
user_id,
sticker,
sticker_format,
))
.await
}
#[doc = "Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success."]
pub async fn verify_chat(&self, chat_id: impl Into<crate::types::ChatId>) -> Result<bool> {
self.execute(&crate::methods::VerifyChat::new(chat_id))
.await
}
#[doc = "Verifies a user on behalf of the organization which is represented by the bot. Returns True on success."]
pub async fn verify_user(&self, user_id: i64) -> Result<bool> {
self.execute(&crate::methods::VerifyUser::new(user_id))
.await
}
}