From 9cc023111de89707e70ea05403bdf99fd8334cb7 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 9 Dec 2022 13:39:29 +0300 Subject: [PATCH] Add sticker.has_text_color. --- td/generate/scheme/td_api.tl | 4 ++-- td/telegram/InlineQueriesManager.cpp | 8 ++++---- td/telegram/StickersManager.cpp | 18 +++++++++++++++--- td/telegram/StickersManager.h | 1 + td/telegram/StickersManager.hpp | 2 ++ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 668061ad5..3a4948aba 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -312,10 +312,10 @@ photo has_stickers:Bool minithumbnail:minithumbnail sizes:vector = Ph //@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 the sticker is a mask -//@custom_emoji_id Identifier of the emoji if the sticker is a custom emoji +//@custom_emoji_id Identifier of the emoji if the sticker is a custom emoji @has_text_color True, if the sticker must be repainted to a text color; for custom emoji only //@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 custom_emoji_id:int64 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 has_text_color:Bool 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 d2c2b9182..eed41df79 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -1269,10 +1269,10 @@ 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_), obj.custom_emoji_id_, - transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_), - obj.is_premium_, copy(obj.premium_animation_), copy(obj.sticker_)); + return td_api::make_object( + obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_), copy(obj.type_), copy(obj.mask_position_), + obj.custom_emoji_id_, obj.has_text_color_, transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_), + obj.is_premium_, copy(obj.premium_animation_), copy(obj.sticker_)); } template <> diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index a2b56a9aa..888fd1dba 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -2228,7 +2228,7 @@ tl_object_ptr StickersManager::get_sticker_object(FileId file_i 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), custom_emoji_id.get(), - get_sticker_minithumbnail(sticker->minithumbnail_, sticker->set_id_, document_id, zoom), + sticker->has_text_color_, 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)); } @@ -2740,8 +2740,19 @@ FileId StickersManager::on_get_sticker(unique_ptr new_sticker, bool rep s->m_thumbnail_ = std::move(new_sticker->m_thumbnail_); is_changed = true; } - s->is_premium_ = new_sticker->is_premium_; - s->premium_animation_file_id_ = new_sticker->premium_animation_file_id_; + if (s->is_premium_ != new_sticker->is_premium_) { + s->is_premium_ = new_sticker->is_premium_; + is_changed = true; + } + if (s->has_text_color_ != new_sticker->has_text_color_) { + s->has_text_color_ = new_sticker->has_text_color_; + is_changed = true; + } + if (s->premium_animation_file_id_ != new_sticker->premium_animation_file_id_ && + new_sticker->premium_animation_file_id_.is_valid()) { + s->premium_animation_file_id_ = new_sticker->premium_animation_file_id_; + is_changed = true; + } if (s->format_ != new_sticker->format_ && new_sticker->format_ != StickerFormat::Unknown) { s->format_ = new_sticker->format_; is_changed = true; @@ -3267,6 +3278,7 @@ void StickersManager::create_sticker(FileId file_id, FileId premium_animation_fi s->alt_ = std::move(custom_emoji->alt_); s->type_ = StickerType::CustomEmoji; s->is_premium_ = !custom_emoji->free_; + s->has_text_color_ = custom_emoji->text_color_; s->emoji_receive_date_ = G()->unix_time(); } s->format_ = format; diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index 717c5e85a..01e177aa1 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -433,6 +433,7 @@ class StickersManager final : public Actor { StickerFormat format_ = StickerFormat::Unknown; StickerType type_ = StickerType::Regular; bool is_premium_ = false; + bool has_text_color_ = false; bool is_from_database_ = false; bool is_being_reloaded_ = false; int32 point_ = -1; diff --git a/td/telegram/StickersManager.hpp b/td/telegram/StickersManager.hpp index b9d17b676..efb0d6c1a 100644 --- a/td/telegram/StickersManager.hpp +++ b/td/telegram/StickersManager.hpp @@ -47,6 +47,7 @@ void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, StorerT STORE_FLAG(is_emoji); STORE_FLAG(sticker->is_premium_); STORE_FLAG(has_emoji_receive_date); + STORE_FLAG(sticker->has_text_color_); END_STORE_FLAGS(); if (!in_sticker_set) { store(sticker->set_id_.get(), storer); @@ -105,6 +106,7 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) { PARSE_FLAG(is_emoji); PARSE_FLAG(sticker->is_premium_); PARSE_FLAG(has_emoji_receive_date); + PARSE_FLAG(sticker->has_text_color_); END_PARSE_FLAGS(); if (is_webm) { sticker->format_ = StickerFormat::Webm;