From 219d5ecf87cfcef7904854e343a8996c43a35eee Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 19 Jul 2022 14:45:37 +0300 Subject: [PATCH] Add sticker.custom_emoji_id. --- td/generate/scheme/td_api.tl | 7 ++++--- td/telegram/InlineQueriesManager.cpp | 2 +- td/telegram/StickersManager.cpp | 11 +++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 12644b46d..cb66ac534 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -260,7 +260,7 @@ stickerTypeRegular = StickerType; //@description The sticker is a mask in WEBP format to be placed on photos or videos stickerTypeMask = StickerType; -//@description The sticker is an emoji to be used inside message text and caption +//@description The sticker is a custom emoji to be used inside message text and caption stickerTypeEmoji = StickerType; @@ -304,10 +304,11 @@ document file_name:string mime_type:string minithumbnail:minithumbnail thumbnail photo has_stickers:Bool minithumbnail:minithumbnail sizes:vector = Photo; //@description Describes a sticker @set_id The identifier of the sticker set to which the sticker belongs; 0 if none @width Sticker width; as defined by the sender @height Sticker height; as defined by the sender -//@emoji Emoji corresponding to the sticker @format Sticker format @type Sticker type @mask_position Position where the mask is placed; may be null even sticker is a mask +//@emoji Emoji corresponding to the sticker @format Sticker format @type Sticker type @mask_position Position where the mask is placed; may be null even the sticker is a mask +//@custom_emoji_id Identifier of the emoji if the sticker is a custom emoji //@outline Sticker's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner //@thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @is_premium True, if only Premium users can use the sticker @premium_animation Premium animation of the sticker; may be null @sticker File containing the sticker -sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat type:StickerType mask_position:maskPosition outline:vector thumbnail:thumbnail is_premium:Bool premium_animation:file sticker:file = Sticker; +sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat type:StickerType mask_position:maskPosition custom_emoji_id:int64 outline:vector thumbnail:thumbnail is_premium:Bool premium_animation:file sticker:file = Sticker; //@description Describes a video file @duration Duration of the video, in seconds; as defined by the sender @width Video width; as defined by the sender @height Video height; as defined by the sender //@file_name Original name of the file; as defined by the sender @mime_type MIME type of the file; as defined by the sender diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index 01a752b19..f1e355706 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -1244,7 +1244,7 @@ tl_object_ptr copy(const td_api::photo &obj) { template <> tl_object_ptr copy(const td_api::sticker &obj) { return td_api::make_object(obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_), - copy(obj.type_), copy(obj.mask_position_), + copy(obj.type_), copy(obj.mask_position_), obj.custom_emoji_id_, transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_), obj.is_premium_, copy(obj.premium_animation_), copy(obj.sticker_)); } diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index bf093efb9..8fb4df418 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1916,7 +1916,8 @@ tl_object_ptr StickersManager::get_sticker_object(FileId file_i const PhotoSize &thumbnail = sticker->m_thumbnail.file_id.is_valid() ? sticker->m_thumbnail : sticker->s_thumbnail; auto thumbnail_format = PhotoFormat::Webp; - int64 document_id = -1; + int64 document_id = 0; + int64 emoji_document_id = 0; if (!sticker->set_id.is_valid()) { auto sticker_file_view = td_->file_manager_->get_file_view(sticker->file_id); if (sticker_file_view.is_encrypted()) { @@ -1934,6 +1935,12 @@ tl_object_ptr StickersManager::get_sticker_object(FileId file_i } } } + } else if (sticker->type == StickerType::Emoji) { + auto sticker_file_view = td_->file_manager_->get_file_view(sticker->file_id); + if (!sticker_file_view.is_encrypted() && sticker_file_view.has_remote_location() && + sticker_file_view.remote_location().is_document()) { + emoji_document_id = sticker_file_view.remote_location().get_id(); + } } auto thumbnail_object = get_thumbnail_object(td_->file_manager_.get(), thumbnail, thumbnail_format); int32 width = sticker->dimensions.width; @@ -1949,7 +1956,7 @@ tl_object_ptr StickersManager::get_sticker_object(FileId file_i : nullptr; return td_api::make_object( sticker->set_id.get(), width, height, sticker->alt, get_sticker_format_object(sticker->format), - get_sticker_type_object(sticker->type), std::move(mask_position), + get_sticker_type_object(sticker->type), std::move(mask_position), emoji_document_id, get_sticker_minithumbnail(sticker->minithumbnail, sticker->set_id, document_id, zoom), std::move(thumbnail_object), sticker->is_premium, std::move(premium_animation_object), td_->file_manager_->get_file_object(file_id));