From 8179a5fd9b2b4e86d6d75a5931c842c455b6bf99 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Sat, 6 Jan 2024 10:40:03 +0200 Subject: [PATCH] Bot API 7.0: Replies 2.0 (#129) * API 7: replies 2.0 * Bot API 7.0: Link Preview Customization (#130) * Bot API 7.0: Link Preview Customization * Bot API 7.0: Multiple Message Actions (#131) * Bot API 7.0: Multiple Message Actions * Bot API 7.0: Request for multiple users (#132) * Bot API 7.0: Request for multiple users * Bot API 7.0: Chat Boost (#133) * Bot API 7.0: Chat Boost * Bot API 7.0: Giveaway (#134) * Bot API 7.0: Giveaway * Bot API 7.0: Other changes (#135) --- examples/async_reply_to_message_updates.rs | 7 +- examples/reply_to_message_updates.rs | 7 +- src/api_params.rs | 218 ++++++----- src/api_traits/async_telegram_api.rs | 33 ++ src/api_traits/telegram_api.rs | 33 ++ src/objects.rs | 432 +++++++++++++++++++-- 6 files changed, 604 insertions(+), 126 deletions(-) diff --git a/examples/async_reply_to_message_updates.rs b/examples/async_reply_to_message_updates.rs index ccddd00..773ff86 100644 --- a/examples/async_reply_to_message_updates.rs +++ b/examples/async_reply_to_message_updates.rs @@ -1,6 +1,7 @@ use frankenstein::AsyncTelegramApi; use frankenstein::GetUpdatesParams; use frankenstein::Message; +use frankenstein::ReplyParameters; use frankenstein::SendMessageParams; use frankenstein::{AsyncApi, UpdateContent}; @@ -42,10 +43,14 @@ async fn main() { } async fn process_message(message: Message, api: AsyncApi) { + let reply_parameters = ReplyParameters::builder() + .message_id(message.message_id) + .build(); + let send_message_params = SendMessageParams::builder() .chat_id(message.chat.id) .text("hello") - .reply_to_message_id(message.message_id) + .reply_parameters(reply_parameters) .build(); if let Err(err) = api.send_message(&send_message_params).await { diff --git a/examples/reply_to_message_updates.rs b/examples/reply_to_message_updates.rs index 07cc5f1..33bd197 100644 --- a/examples/reply_to_message_updates.rs +++ b/examples/reply_to_message_updates.rs @@ -1,4 +1,5 @@ use frankenstein::GetUpdatesParams; +use frankenstein::ReplyParameters; use frankenstein::SendMessageParams; use frankenstein::TelegramApi; use frankenstein::{Api, UpdateContent}; @@ -20,10 +21,14 @@ fn main() { Ok(response) => { for update in response.result { if let UpdateContent::Message(message) = update.content { + let reply_parameters = ReplyParameters::builder() + .message_id(message.message_id) + .build(); + let send_message_params = SendMessageParams::builder() .chat_id(message.chat.id) .text("hello") - .reply_to_message_id(message.message_id) + .reply_parameters(reply_parameters) .build(); if let Err(err) = api.send_message(&send_message_params) { diff --git a/src/api_params.rs b/src/api_params.rs index 7688aec..0f925f4 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -7,13 +7,13 @@ use crate::objects::{ InlineQueryResultCachedVoice, InlineQueryResultContact, InlineQueryResultDocument, InlineQueryResultGame, InlineQueryResultGif, InlineQueryResultLocation, InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVenue, - InlineQueryResultVideo, InlineQueryResultVoice, InputSticker, LabeledPrice, MaskPosition, - MenuButton, MessageEntity, PassportElementErrorDataField, PassportElementErrorFile, - PassportElementErrorFiles, PassportElementErrorFrontSide, PassportElementErrorReverseSide, - PassportElementErrorSelfie, PassportElementErrorTranslationFile, - PassportElementErrorTranslationFiles, PassportElementErrorUnspecified, PollType, ReactionType, - ReplyKeyboardMarkup, ReplyKeyboardRemove, ShippingOption, StickerFormat, StickerType, - WebAppInfo, + InlineQueryResultVideo, InlineQueryResultVoice, InputSticker, LabeledPrice, LinkPreviewOptions, + MaskPosition, MenuButton, MessageEntity, PassportElementErrorDataField, + PassportElementErrorFile, PassportElementErrorFiles, PassportElementErrorFrontSide, + PassportElementErrorReverseSide, PassportElementErrorSelfie, + PassportElementErrorTranslationFile, PassportElementErrorTranslationFiles, + PassportElementErrorUnspecified, PollType, ReactionType, ReplyKeyboardMarkup, + ReplyKeyboardRemove, ShippingOption, StickerFormat, StickerType, WebAppInfo, }; use crate::{AllowedUpdate, ParseMode}; use serde::Deserialize; @@ -298,7 +298,7 @@ pub struct SendMessageParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub disable_web_page_preview: Option, + pub link_preview_options: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -310,11 +310,7 @@ pub struct SendMessageParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -344,6 +340,29 @@ pub struct ForwardMessageParams { pub message_id: i32, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct ForwardMessagesParams { + #[builder(setter(into))] + pub chat_id: ChatId, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub message_thread_id: Option, + + #[builder(setter(into))] + pub from_chat_id: ChatId, + + pub message_ids: Vec, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub disable_notification: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub protect_content: Option, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct CopyMessageParams { #[builder(setter(into))] @@ -380,15 +399,38 @@ pub struct CopyMessageParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_markup: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct CopyMessagesParams { + #[builder(setter(into))] + pub chat_id: ChatId, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_markup: Option, + pub message_thread_id: Option, + + #[builder(setter(into))] + pub from_chat_id: ChatId, + + pub message_ids: Vec, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub disable_notification: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub protect_content: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub remove_caption: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -429,11 +471,7 @@ pub struct SendPhotoParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -490,11 +528,7 @@ pub struct SendAudioParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -543,11 +577,7 @@ pub struct SendDocumentParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -612,11 +642,7 @@ pub struct SendVideoParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -677,11 +703,7 @@ pub struct SendAnimationParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -726,11 +748,7 @@ pub struct SendVoiceParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -771,11 +789,7 @@ pub struct SendVideoNoteParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -803,11 +817,7 @@ pub struct SendMediaGroupParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] @@ -849,11 +859,7 @@ pub struct SendLocationParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -959,11 +965,7 @@ pub struct SendVenueParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -1003,11 +1005,7 @@ pub struct SendContactParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -1078,11 +1076,7 @@ pub struct SendPollParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -1112,11 +1106,7 @@ pub struct SendDiceParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -1632,6 +1622,14 @@ pub struct AnswerCallbackQueryParams { pub cache_time: Option, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct GetUserChatBoostsParams { + #[builder(setter(into))] + pub chat_id: ChatId, + + pub user_id: u64, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct SetMyCommandsParams { pub commands: Vec, @@ -1748,7 +1746,7 @@ pub struct EditMessageTextParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub disable_web_page_preview: Option, + pub link_preview_options: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -1847,6 +1845,14 @@ pub struct DeleteMessageParams { pub message_id: i32, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct DeleteMessagesParams { + #[builder(setter(into))] + pub chat_id: ChatId, + + pub message_ids: Vec, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct SendStickerParams { #[builder(setter(into))] @@ -1873,11 +1879,7 @@ pub struct SendStickerParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -2150,11 +2152,7 @@ pub struct SendInvoiceParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -2293,11 +2291,7 @@ pub struct SendGameParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub allow_sending_without_reply: Option, + pub reply_parameters: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -2553,5 +2547,35 @@ pub struct GetChatMenuButtonParams { #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct UnpinAllGeneralForumTopicMessagesParams { + #[builder(setter(into))] pub chat_id: ChatId, } + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct ReplyParameters { + pub message_id: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub chat_id: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub allow_sending_without_reply: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub quote: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub quote_parse_mode: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub quote_entities: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub quote_position: Option, +} diff --git a/src/api_traits/async_telegram_api.rs b/src/api_traits/async_telegram_api.rs index c1c5565..85edcb7 100644 --- a/src/api_traits/async_telegram_api.rs +++ b/src/api_traits/async_telegram_api.rs @@ -12,6 +12,7 @@ use crate::api_params::BanChatSenderChatParams; use crate::api_params::CloseForumTopicParams; use crate::api_params::CloseGeneralForumTopicParams; use crate::api_params::CopyMessageParams; +use crate::api_params::CopyMessagesParams; use crate::api_params::CreateChatInviteLinkParams; use crate::api_params::CreateForumTopicParams; use crate::api_params::CreateInvoiceLinkParams; @@ -21,6 +22,7 @@ use crate::api_params::DeleteChatPhotoParams; use crate::api_params::DeleteChatStickerSetParams; use crate::api_params::DeleteForumTopicParams; use crate::api_params::DeleteMessageParams; +use crate::api_params::DeleteMessagesParams; use crate::api_params::DeleteMyCommandsParams; use crate::api_params::DeleteStickerFromSetParams; use crate::api_params::DeleteStickerSetParams; @@ -36,6 +38,7 @@ use crate::api_params::EditMessageTextParams; use crate::api_params::ExportChatInviteLinkParams; use crate::api_params::FileUpload; use crate::api_params::ForwardMessageParams; +use crate::api_params::ForwardMessagesParams; use crate::api_params::GetChatAdministratorsParams; use crate::api_params::GetChatMemberCountParams; use crate::api_params::GetChatMemberParams; @@ -51,6 +54,7 @@ use crate::api_params::GetMyNameParams; use crate::api_params::GetMyShortDescriptionParams; use crate::api_params::GetStickerSetParams; use crate::api_params::GetUpdatesParams; +use crate::api_params::GetUserChatBoostsParams; use crate::api_params::GetUserProfilePhotosParams; use crate::api_params::HideGeneralForumTopicParams; use crate::api_params::InputMedia; @@ -131,6 +135,7 @@ use crate::objects::SentWebAppMessage; use crate::objects::StickerSet; use crate::objects::Update; use crate::objects::User; +use crate::objects::UserChatBoosts; use crate::objects::UserProfilePhotos; use crate::objects::WebhookInfo; use crate::Sticker; @@ -193,6 +198,13 @@ pub trait AsyncTelegramApi { self.request("forwardMessage", Some(params)).await } + async fn forward_messages( + &self, + params: &ForwardMessagesParams, + ) -> Result>, Self::Error> { + self.request("forwardMessages", Some(params)).await + } + async fn copy_message( &self, params: &CopyMessageParams, @@ -200,6 +212,13 @@ pub trait AsyncTelegramApi { self.request("copyMessage", Some(params)).await } + async fn copy_messages( + &self, + params: &CopyMessagesParams, + ) -> Result>, Self::Error> { + self.request("copyMessages", Some(params)).await + } + async fn send_photo( &self, params: &SendPhotoParams, @@ -798,6 +817,13 @@ pub trait AsyncTelegramApi { self.request("answerCallbackQuery", Some(params)).await } + async fn get_user_chat_boosts( + &self, + params: &GetUserChatBoostsParams, + ) -> Result, Self::Error> { + self.request("getUserChatBoosts", Some(params)).await + } + async fn get_my_commands( &self, params: &GetMyCommandsParams, @@ -1031,6 +1057,13 @@ pub trait AsyncTelegramApi { self.request("deleteMessage", Some(params)).await } + async fn delete_messages( + &self, + params: &DeleteMessagesParams, + ) -> Result, Self::Error> { + self.request("deleteMessages", Some(params)).await + } + async fn send_sticker( &self, params: &SendStickerParams, diff --git a/src/api_traits/telegram_api.rs b/src/api_traits/telegram_api.rs index c8a38d8..1fa8271 100644 --- a/src/api_traits/telegram_api.rs +++ b/src/api_traits/telegram_api.rs @@ -12,6 +12,7 @@ use crate::api_params::BanChatSenderChatParams; use crate::api_params::CloseForumTopicParams; use crate::api_params::CloseGeneralForumTopicParams; use crate::api_params::CopyMessageParams; +use crate::api_params::CopyMessagesParams; use crate::api_params::CreateChatInviteLinkParams; use crate::api_params::CreateForumTopicParams; use crate::api_params::CreateInvoiceLinkParams; @@ -21,6 +22,7 @@ use crate::api_params::DeleteChatPhotoParams; use crate::api_params::DeleteChatStickerSetParams; use crate::api_params::DeleteForumTopicParams; use crate::api_params::DeleteMessageParams; +use crate::api_params::DeleteMessagesParams; use crate::api_params::DeleteMyCommandsParams; use crate::api_params::DeleteStickerFromSetParams; use crate::api_params::DeleteStickerSetParams; @@ -36,6 +38,7 @@ use crate::api_params::EditMessageTextParams; use crate::api_params::ExportChatInviteLinkParams; use crate::api_params::FileUpload; use crate::api_params::ForwardMessageParams; +use crate::api_params::ForwardMessagesParams; use crate::api_params::GetChatAdministratorsParams; use crate::api_params::GetChatMemberCountParams; use crate::api_params::GetChatMemberParams; @@ -50,6 +53,7 @@ use crate::api_params::GetMyNameParams; use crate::api_params::GetMyShortDescriptionParams; use crate::api_params::GetStickerSetParams; use crate::api_params::GetUpdatesParams; +use crate::api_params::GetUserChatBoostsParams; use crate::api_params::GetUserProfilePhotosParams; use crate::api_params::HideGeneralForumTopicParams; use crate::api_params::InputMedia; @@ -130,6 +134,7 @@ use crate::objects::SentWebAppMessage; use crate::objects::StickerSet; use crate::objects::Update; use crate::objects::User; +use crate::objects::UserChatBoosts; use crate::objects::UserProfilePhotos; use crate::objects::WebhookInfo; use crate::GetCustomEmojiStickersParams; @@ -188,6 +193,13 @@ pub trait TelegramApi { self.request("forwardMessage", Some(params)) } + fn forward_messages( + &self, + params: &ForwardMessagesParams, + ) -> Result>, Self::Error> { + self.request("forwardMessages", Some(params)) + } + fn copy_message( &self, params: &CopyMessageParams, @@ -195,6 +207,13 @@ pub trait TelegramApi { self.request("copyMessage", Some(params)) } + fn copy_messages( + &self, + params: &CopyMessagesParams, + ) -> Result>, Self::Error> { + self.request("copyMessages", Some(params)) + } + fn send_photo(&self, params: &SendPhotoParams) -> Result, Self::Error> { let method_name = "sendPhoto"; let mut files: Vec<(&str, PathBuf)> = vec![]; @@ -753,6 +772,13 @@ pub trait TelegramApi { self.request("answerCallbackQuery", Some(params)) } + fn get_user_chat_boosts( + &self, + params: &GetUserChatBoostsParams, + ) -> Result, Self::Error> { + self.request("getUserChatBoosts", Some(params)) + } + fn get_my_commands( &self, params: &GetMyCommandsParams, @@ -979,6 +1005,13 @@ pub trait TelegramApi { self.request("deleteMessage", Some(params)) } + fn delete_messages( + &self, + params: &DeleteMessagesParams, + ) -> Result, Self::Error> { + self.request("deleteMessages", Some(params)) + } + fn send_sticker( &self, params: &SendStickerParams, diff --git a/src/objects.rs b/src/objects.rs index 65cdef7..519e6b7 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -357,6 +357,8 @@ pub enum UpdateContent { MyChatMember(ChatMemberUpdated), ChatMember(ChatMemberUpdated), ChatJoinRequest(ChatJoinRequest), + ChatBoost(ChatBoost), + RemovedChatBoost(ChatBoostRemoved), } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -416,6 +418,8 @@ pub enum AllowedUpdate { MyChatMember, ChatMember, ChatJoinRequest, + ChatBoost, + RemovedChatBoost, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -499,6 +503,22 @@ pub struct Chat { #[builder(setter(into, strip_option), default)] pub available_reactions: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub accent_color_id: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub background_custom_emoji_id: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub profile_accent_color_id: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub profile_background_custom_emoji_id: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub emoji_status_custom_emoji_id: Option, @@ -563,6 +583,10 @@ pub struct Chat { #[builder(setter(into, strip_option), default)] pub has_protected_content: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub has_visible_history: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub sticker_set_name: Option, @@ -603,39 +627,27 @@ pub struct Message { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub forward_from: Option>, + pub forward_origin: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub forward_from_chat: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub forward_from_message_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub forward_signature: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - #[builder(setter(into, strip_option), default)] - pub forward_sender_name: Option, + pub is_topic_message: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub forward_date: Option, + pub is_automatic_forward: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub is_topic_message: Option, + pub reply_to_message: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub is_automatic_forward: Option, + pub external_reply: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub reply_to_message: Option>, + pub quote: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -665,6 +677,10 @@ pub struct Message { #[builder(setter(into, strip_option), default)] pub entities: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub link_preview_options: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub animation: Option>, @@ -783,7 +799,7 @@ pub struct Message { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub pinned_message: Option>, + pub pinned_message: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -795,7 +811,7 @@ pub struct Message { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] - pub user_shared: Option>, + pub users_shared: Option>, #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] @@ -841,6 +857,22 @@ pub struct Message { #[builder(setter(into, strip_option), default)] pub general_forum_topic_unhidden: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub giveaway_created: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub giveaway: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub giveaway_winners: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub giveaway_completed: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub video_chat_started: Option>, @@ -897,6 +929,184 @@ pub struct MessageEntity { pub custom_emoji_id: Option, } +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct TextQuote { + #[builder(setter(into))] + pub text: String, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub entities: Option>, + + pub position: u32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub is_manual: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Builder)] +pub struct ExternalReplyInfo { + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub origin: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub chain: Option, + + pub message_id: i32, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub link_preview_options: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub animation: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub audio: Option