diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0fd845be1..6cb5db858 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -257,8 +257,8 @@ stickerFormatWebm = StickerFormat; //@description The sticker is a regular sticker stickerTypeRegular = StickerType; -//@description The sticker is a mask in WEBP format to be placed on photos or videos @mask_position Position where the mask is placed; may be null -stickerTypeMask mask_position:maskPosition = StickerType; +//@description The sticker is a mask in WEBP format to be placed on photos or videos +stickerTypeMask = StickerType; //@description Represents a closed vector path. The path begins at the end point of the last command @commands List of vector path commands @@ -301,9 +301,10 @@ 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 @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 +//@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 +//@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 @premium_animation Premium animation of the sticker; may be null. If present, only Premium users can send the sticker @sticker File containing the sticker -sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat type:StickerType outline:vector thumbnail:thumbnail premium_animation:file sticker:file = Sticker; +sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat type:StickerType mask_position:maskPosition outline:vector thumbnail:thumbnail 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 @@ -4004,7 +4005,8 @@ proxies proxies:vector = Proxies; //@emojis Emojis corresponding to the sticker //@format Sticker format //@type Sticker type -inputSticker sticker:InputFile emojis:string format:StickerFormat type:StickerType = InputSticker; +//@mask_position Position where the mask is placed; pass null if not specified +inputSticker sticker:InputFile emojis:string format:StickerFormat type:StickerType mask_position:maskPosition = InputSticker; //@description Represents a date range @start_date Point in time (Unix timestamp) at which the date range begins @end_date Point in time (Unix timestamp) at which the date range ends diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index bbaa1e98e..0de394c00 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -1167,10 +1167,8 @@ tl_object_ptr copy(const td_api::StickerType &obj) { switch (obj.get_id()) { case td_api::stickerTypeRegular::ID: return td_api::make_object(); - case td_api::stickerTypeMask::ID: { - auto &mask_position = static_cast(obj).mask_position_; - return td_api::make_object(copy(mask_position)); - } + case td_api::stickerTypeMask::ID: + return td_api::make_object(); default: UNREACHABLE(); } @@ -1244,8 +1242,9 @@ 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_), transform(obj.outline_, copy_closed_vector_path), - copy(obj.thumbnail_), copy(obj.premium_animation_), copy(obj.sticker_)); + copy(obj.type_), copy(obj.mask_position_), + transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_), + copy(obj.premium_animation_), copy(obj.sticker_)); } template <> diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 2facaa991..a75e8fbfc 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1898,7 +1898,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), nullptr, - get_sticker_minithumbnail(sticker->minithumbnail, sticker->set_id, document_id, zoom), + std::move(mask_position), get_sticker_minithumbnail(sticker->minithumbnail, sticker->set_id, document_id, zoom), std::move(thumbnail_object), std::move(premium_animation_object), td_->file_manager_->get_file_object(file_id)); } @@ -5898,8 +5898,7 @@ tl_object_ptr StickersManager::get_input_stic tl_object_ptr mask_coords; if (sticker->type_ != nullptr && sticker->type_->get_id() == td_api::stickerTypeMask::ID) { - auto sticker_type = static_cast(sticker->type_.get()); - auto mask_position = sticker_type->mask_position_.get(); + auto mask_position = sticker->mask_position_.get(); if (mask_position != nullptr && mask_position->point_ != nullptr) { auto point = [mask_point_id = mask_position->point_->get_id()] { switch (mask_point_id) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 1e7270e31..2104cc866 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -548,13 +548,20 @@ class CliClient final : public Actor { static td_api::object_ptr as_sticker_type(string sticker_type) { if (!sticker_type.empty() && sticker_type.back() == 'm') { - auto position = td_api::make_object(td_api::make_object(), - Random::fast(-5, 5), Random::fast(-5, 5), 1.0); - return td_api::make_object(Random::fast_bool() ? nullptr : std::move(position)); + return td_api::make_object(); } return Random::fast_bool() ? nullptr : td_api::make_object(); } + static td_api::object_ptr as_mask_position(string sticker_type) { + if (!sticker_type.empty() && sticker_type.back() == 'm') { + auto position = td_api::make_object(td_api::make_object(), + Random::fast(-5, 5), Random::fast(-5, 5), 1.0); + return Random::fast_bool() ? nullptr : std::move(position); + } + return nullptr; + } + static int32 as_limit(Slice str, int32 default_limit = 10) { if (str.empty()) { return default_limit; @@ -2717,7 +2724,7 @@ class CliClient final : public Actor { } else if (op == "usf" || op == "usfa" || op == "usfv" || op == "usfm") { send_request(td_api::make_object( -1, td_api::make_object(as_input_file(args), "😀", as_sticker_format(op), - as_sticker_type(op)))); + as_sticker_type(op), as_mask_position(op)))); } else if (op == "cnss" || op == "cnssa" || op == "cnssv" || op == "cnssm") { string title; string name; @@ -2726,7 +2733,7 @@ class CliClient final : public Actor { auto input_stickers = transform(autosplit(stickers), [op](Slice sticker) -> td_api::object_ptr { return td_api::make_object(as_input_file(sticker), "😀", as_sticker_format(op), - as_sticker_type(op)); + as_sticker_type(op), as_mask_position(op)); }); send_request( td_api::make_object(my_id_, title, name, std::move(input_stickers), "tg_cli"));