From c94c448f95e4576c252c9a5d719909c2d52e5c10 Mon Sep 17 00:00:00 2001 From: pxp9 Date: Fri, 5 Jul 2024 16:50:32 +0200 Subject: [PATCH] feat: add method sendPaidMedia --- src/api_params.rs | 47 +++++++++++++++++++++++++--- src/api_traits/async_telegram_api.rs | 8 +++++ src/api_traits/telegram_api.rs | 8 +++++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/api_params.rs b/src/api_params.rs index 2db49c2..ea658b2 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -7,10 +7,10 @@ use crate::objects::{ InlineQueryResultCachedVoice, InlineQueryResultContact, InlineQueryResultDocument, InlineQueryResultGame, InlineQueryResultGif, InlineQueryResultLocation, InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVenue, - InlineQueryResultVideo, InlineQueryResultVoice, InputPollOption, InputSticker, LabeledPrice, - LinkPreviewOptions, MaskPosition, MenuButton, MessageEntity, PassportElementErrorDataField, - PassportElementErrorFile, PassportElementErrorFiles, PassportElementErrorFrontSide, - PassportElementErrorReverseSide, PassportElementErrorSelfie, + InlineQueryResultVideo, InlineQueryResultVoice, InputPaidMedia, InputPollOption, InputSticker, + LabeledPrice, LinkPreviewOptions, MaskPosition, MenuButton, MessageEntity, + PassportElementErrorDataField, PassportElementErrorFile, PassportElementErrorFiles, + PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorTranslationFile, PassportElementErrorTranslationFiles, PassportElementErrorUnspecified, PollType, ReactionType, ReplyKeyboardMarkup, ReplyKeyboardRemove, ShippingOption, StickerFormat, StickerType, WebAppInfo, @@ -2796,6 +2796,45 @@ pub struct UnpinAllGeneralForumTopicMessagesParams { pub chat_id: ChatId, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)] +pub struct SendPaidMediaParams { + pub chat_id: ChatId, + pub star_count: i32, + pub media: Vec, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub caption: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub parse_mode: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub caption_entities: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub show_caption_above_media: Option, + + #[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 reply_parameters: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub reply_markup: Option, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct ReplyParameters { pub message_id: i32, diff --git a/src/api_traits/async_telegram_api.rs b/src/api_traits/async_telegram_api.rs index ce956d6..ed72a50 100644 --- a/src/api_traits/async_telegram_api.rs +++ b/src/api_traits/async_telegram_api.rs @@ -81,6 +81,7 @@ use crate::api_params::SendInvoiceParams; use crate::api_params::SendLocationParams; use crate::api_params::SendMediaGroupParams; use crate::api_params::SendMessageParams; +use crate::api_params::SendPaidMediaParams; use crate::api_params::SendPhotoParams; use crate::api_params::SendPollParams; use crate::api_params::SendStickerParams; @@ -1361,6 +1362,13 @@ pub trait AsyncTelegramApi { .await } + async fn send_paid_media( + &self, + params: SendPaidMediaParams, + ) -> Result, Self::Error> { + self.request("sendPaidMedia", Some(params)).await + } + async fn request_without_body( &self, method: &str, diff --git a/src/api_traits/telegram_api.rs b/src/api_traits/telegram_api.rs index a908643..ec464ae 100644 --- a/src/api_traits/telegram_api.rs +++ b/src/api_traits/telegram_api.rs @@ -80,6 +80,7 @@ use crate::api_params::SendInvoiceParams; use crate::api_params::SendLocationParams; use crate::api_params::SendMediaGroupParams; use crate::api_params::SendMessageParams; +use crate::api_params::SendPaidMediaParams; use crate::api_params::SendPhotoParams; use crate::api_params::SendPollParams; use crate::api_params::SendStickerParams; @@ -1298,6 +1299,13 @@ pub trait TelegramApi { self.request("unpinAllGeneralForumTopicMessages", Some(params)) } + fn send_paid_media( + &self, + params: SendPaidMediaParams, + ) -> Result, Self::Error> { + self.request("sendPaidMedia", Some(params)) + } + fn request_without_body( &self, method: &str,