From cf1b73b8b21149da382600230aa68fceac881d2a Mon Sep 17 00:00:00 2001 From: Akshett Rai Jindal Date: Tue, 20 Aug 2024 20:58:32 +0530 Subject: [PATCH] Add `format` parameter to `SetStickerSetThumbnail` --- crates/teloxide-core/schema.ron | 5 +++++ crates/teloxide-core/src/bot/api.rs | 13 +++++++++---- crates/teloxide-core/src/local_macros.rs | 4 ++-- .../src/payloads/set_sticker_set_thumbnail.rs | 4 +++- crates/teloxide-core/src/requests/requester.rs | 1 + 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index 8f0e0996..91837a2e 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -3915,6 +3915,11 @@ Schema( md_links: {"More info on Sending Files ยป": "https://core.telegram.org/bots/api#sending-files"}, ), ), + Param( + name: "format", + ty: RawTy("StickerFormat"), + descr: Doc(md: "Format of the thumbnail, must be one of \"static\" for a .WEBP or .PNG image, \"animated\" for a .TGS animation, or \"video\" for a WEBM video") + ) ], ), Method( diff --git a/crates/teloxide-core/src/bot/api.rs b/crates/teloxide-core/src/bot/api.rs index 26ce46f0..0b57b14b 100644 --- a/crates/teloxide-core/src/bot/api.rs +++ b/crates/teloxide-core/src/bot/api.rs @@ -6,7 +6,7 @@ use crate::{ requests::{JsonRequest, MultipartRequest}, types::{ BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia, - InputSticker, LabeledPrice, MessageId, Recipient, ThreadId, UserId, + InputSticker, LabeledPrice, MessageId, Recipient, StickerFormat, ThreadId, UserId, }, Bot, }; @@ -1173,7 +1173,7 @@ impl Requester for Bot { &self, user_id: UserId, sticker: InputFile, - sticker_format: crate::types::StickerFormat, + sticker_format: StickerFormat, ) -> Self::UploadStickerFile { Self::UploadStickerFile::new( self.clone(), @@ -1269,13 +1269,18 @@ impl Requester for Bot { type SetStickerSetThumbnail = MultipartRequest; - fn set_sticker_set_thumbnail(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumbnail + fn set_sticker_set_thumbnail( + &self, + name: N, + user_id: UserId, + format: StickerFormat, + ) -> Self::SetStickerSetThumbnail where N: Into, { Self::SetStickerSetThumbnail::new( self.clone(), - payloads::SetStickerSetThumbnail::new(name, user_id), + payloads::SetStickerSetThumbnail::new(name, user_id, format), ) } diff --git a/crates/teloxide-core/src/local_macros.rs b/crates/teloxide-core/src/local_macros.rs index e8f4e794..10d158d3 100644 --- a/crates/teloxide-core/src/local_macros.rs +++ b/crates/teloxide-core/src/local_macros.rs @@ -1351,9 +1351,9 @@ macro_rules! requester_forward { (@method set_sticker_set_thumbnail $body:ident $ty:ident) => { type SetStickerSetThumbnail = $ty![SetStickerSetThumbnail]; - fn set_sticker_set_thumbnail(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumbnail where N: Into { + fn set_sticker_set_thumbnail(&self, name: N, user_id: UserId, format: StickerFormat) -> Self::SetStickerSetThumbnail where N: Into { let this = self; - $body!(set_sticker_set_thumbnail this (name: N, user_id: UserId)) + $body!(set_sticker_set_thumbnail this (name: N, user_id: UserId, format: StickerFormat)) } }; (@method set_custom_emoji_sticker_set_thumbnail $body:ident $ty:ident) => { diff --git a/crates/teloxide-core/src/payloads/set_sticker_set_thumbnail.rs b/crates/teloxide-core/src/payloads/set_sticker_set_thumbnail.rs index 4c0d6835..0c1d0690 100644 --- a/crates/teloxide-core/src/payloads/set_sticker_set_thumbnail.rs +++ b/crates/teloxide-core/src/payloads/set_sticker_set_thumbnail.rs @@ -2,7 +2,7 @@ use serde::Serialize; -use crate::types::{InputFile, True, UserId}; +use crate::types::{InputFile, StickerFormat, True, UserId}; impl_payload! { @[multipart = thumbnail] @@ -14,6 +14,8 @@ impl_payload! { pub name: String [into], /// User identifier of sticker file owner pub user_id: UserId, + /// Format of the thumbnail, must be one of "static" for a .WEBP or .PNG image, "animated" for a .TGS animation, or "video" for a WEBM video + pub format: StickerFormat, } optional { /// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. diff --git a/crates/teloxide-core/src/requests/requester.rs b/crates/teloxide-core/src/requests/requester.rs index 204d6d9c..6246f50b 100644 --- a/crates/teloxide-core/src/requests/requester.rs +++ b/crates/teloxide-core/src/requests/requester.rs @@ -1128,6 +1128,7 @@ pub trait Requester { &self, name: N, user_id: UserId, + format: StickerFormat, ) -> Self::SetStickerSetThumbnail where N: Into;