Add format parameter to SetStickerSetThumbnail

This commit is contained in:
Akshett Rai Jindal 2024-08-20 20:58:32 +05:30
parent 2655607320
commit cf1b73b8b2
5 changed files with 20 additions and 7 deletions

View file

@ -3915,6 +3915,11 @@ Schema(
md_links: {"More info on Sending Files »": "https://core.telegram.org/bots/api#sending-files"}, 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( Method(

View file

@ -6,7 +6,7 @@ use crate::{
requests::{JsonRequest, MultipartRequest}, requests::{JsonRequest, MultipartRequest},
types::{ types::{
BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia, BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia,
InputSticker, LabeledPrice, MessageId, Recipient, ThreadId, UserId, InputSticker, LabeledPrice, MessageId, Recipient, StickerFormat, ThreadId, UserId,
}, },
Bot, Bot,
}; };
@ -1173,7 +1173,7 @@ impl Requester for Bot {
&self, &self,
user_id: UserId, user_id: UserId,
sticker: InputFile, sticker: InputFile,
sticker_format: crate::types::StickerFormat, sticker_format: StickerFormat,
) -> Self::UploadStickerFile { ) -> Self::UploadStickerFile {
Self::UploadStickerFile::new( Self::UploadStickerFile::new(
self.clone(), self.clone(),
@ -1269,13 +1269,18 @@ impl Requester for Bot {
type SetStickerSetThumbnail = MultipartRequest<payloads::SetStickerSetThumbnail>; type SetStickerSetThumbnail = MultipartRequest<payloads::SetStickerSetThumbnail>;
fn set_sticker_set_thumbnail<N>(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumbnail fn set_sticker_set_thumbnail<N>(
&self,
name: N,
user_id: UserId,
format: StickerFormat,
) -> Self::SetStickerSetThumbnail
where where
N: Into<String>, N: Into<String>,
{ {
Self::SetStickerSetThumbnail::new( Self::SetStickerSetThumbnail::new(
self.clone(), self.clone(),
payloads::SetStickerSetThumbnail::new(name, user_id), payloads::SetStickerSetThumbnail::new(name, user_id, format),
) )
} }

View file

@ -1351,9 +1351,9 @@ macro_rules! requester_forward {
(@method set_sticker_set_thumbnail $body:ident $ty:ident) => { (@method set_sticker_set_thumbnail $body:ident $ty:ident) => {
type SetStickerSetThumbnail = $ty![SetStickerSetThumbnail]; type SetStickerSetThumbnail = $ty![SetStickerSetThumbnail];
fn set_sticker_set_thumbnail<N>(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumbnail where N: Into<String> { fn set_sticker_set_thumbnail<N>(&self, name: N, user_id: UserId, format: StickerFormat) -> Self::SetStickerSetThumbnail where N: Into<String> {
let this = self; 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) => { (@method set_custom_emoji_sticker_set_thumbnail $body:ident $ty:ident) => {

View file

@ -2,7 +2,7 @@
use serde::Serialize; use serde::Serialize;
use crate::types::{InputFile, True, UserId}; use crate::types::{InputFile, StickerFormat, True, UserId};
impl_payload! { impl_payload! {
@[multipart = thumbnail] @[multipart = thumbnail]
@ -14,6 +14,8 @@ impl_payload! {
pub name: String [into], pub name: String [into],
/// User identifier of sticker file owner /// User identifier of sticker file owner
pub user_id: UserId, 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 { 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. /// 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.

View file

@ -1128,6 +1128,7 @@ pub trait Requester {
&self, &self,
name: N, name: N,
user_id: UserId, user_id: UserId,
format: StickerFormat,
) -> Self::SetStickerSetThumbnail ) -> Self::SetStickerSetThumbnail
where where
N: Into<String>; N: Into<String>;