diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0b0292236..0771082d7 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -270,8 +270,8 @@ 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 @is_animated True, if the sticker is an animated sticker in TGS format @is_mask True, if the sticker is a mask @mask_position Position where the mask should be placed; may be null -//@thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @sticker File containing the sticker -sticker set_id:int64 width:int32 height:int32 emoji:string is_animated:Bool is_mask:Bool mask_position:maskPosition thumbnail:thumbnail sticker:file = Sticker; +//@cover Sticker cover in an SVG format; may be empty @thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @sticker File containing the sticker +sticker set_id:int64 width:int32 height:int32 emoji:string is_animated:Bool is_mask:Bool mask_position:maskPosition cover:string thumbnail:thumbnail 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/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 9379f8423..825cc0800 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index d2d60bc49..45702d942 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -957,7 +957,7 @@ tl_object_ptr copy(const td_api::photo &obj) { template <> tl_object_ptr copy(const td_api::sticker &obj) { return make_tl_object(obj.set_id_, obj.width_, obj.height_, obj.emoji_, obj.is_animated_, - obj.is_mask_, copy(obj.mask_position_), copy(obj.thumbnail_), + obj.is_mask_, copy(obj.mask_position_), obj.cover_, copy(obj.thumbnail_), copy(obj.sticker_)); } diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 32fac339e..2e93cdf86 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1334,6 +1334,40 @@ tl_object_ptr StickersManager::get_mask_point_object(int32 po } } +string StickersManager::get_sticker_minithumbnail(const string &path) { + if (path.empty()) { + return string(); + } + + const auto prefix = Slice( + ""); + + auto buf = StackAllocator::alloc(1 << 7); + StringBuilder sb(buf.as_slice(), true); + + sb << prefix; + for (unsigned char c : path) { + if (c >= 128 + 64) { + sb << "AACAAAAHAAALMAAAQASTAVAAAZaacaaaahaaalmaaaqastava.az0123456789-,"[c - 128 - 64]; + } else { + if (c >= 128) { + sb << ','; + } else if (c >= 64) { + sb << '-'; + } + sb << (c & 63); + } + } + sb << suffix; + + CHECK(!sb.is_error()); + return sb.as_cslice().str(); +} + tl_object_ptr StickersManager::get_sticker_object(FileId file_id) const { if (!file_id.is_valid()) { return nullptr; @@ -1362,7 +1396,8 @@ tl_object_ptr StickersManager::get_sticker_object(FileId file_i auto thumbnail_object = get_thumbnail_object(td_->file_manager_.get(), thumbnail, thumbnail_format); return make_tl_object(sticker->set_id.get(), sticker->dimensions.width, sticker->dimensions.height, sticker->alt, sticker->is_animated, sticker->is_mask, std::move(mask_position), - std::move(thumbnail_object), td_->file_manager_->get_file_object(file_id)); + get_sticker_minithumbnail(sticker->minithumbnail), std::move(thumbnail_object), + td_->file_manager_->get_file_object(file_id)); } tl_object_ptr StickersManager::get_stickers_object(const vector &sticker_ids) const { diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index 7e4ec1254..ae4032d29 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -393,6 +393,8 @@ class StickersManager : public Actor { class UploadStickerFileCallback; + static string get_sticker_minithumbnail(const string &path); + static tl_object_ptr get_mask_point_object(int32 point); tl_object_ptr get_sticker_set_info_object(StickerSetId sticker_set_id,