diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 3dee11806..a9a16990f 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -5023,12 +5023,13 @@ proxies proxies:vector = Proxies; //@description A sticker to be added to a sticker set -//@sticker File with the sticker; must fit in a 512x512 square. For WEBP stickers and masks the file must be in PNG format, which will be converted to WEBP server-side. -//-Otherwise, the file must be local or uploaded within a week. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements +//@sticker File with the sticker; must fit in a 512x512 square. For WEBP stickers the file must be in PNG format, which will be converted to WEBP server-side. +//-See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements //@emojis Emojis corresponding to the sticker //@format Sticker format //@mask_position Position where the mask is placed; pass null if not specified -inputSticker sticker:InputFile emojis:string format:StickerFormat mask_position:maskPosition = InputSticker; +//@keywords List of up to 20 keywords with total length up to 64 characters, which can be used to find the sticker +inputSticker sticker:InputFile emojis:string format:StickerFormat mask_position:maskPosition keywords:vector = 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/StickersManager.cpp b/td/telegram/StickersManager.cpp index 76d1f75ae..080a0a25e 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -7919,6 +7919,17 @@ Result> StickersManager::prepare_i return Status::Error(400, "Emojis must be encoded in UTF-8"); } + for (auto &keyword : sticker->keywords_) { + if (!clean_input_string(keyword)) { + return Status::Error(400, "Keywords must be encoded in UTF-8"); + } + for (auto &c : keyword) { + if (c == ',' || c == '\n') { + c = ' '; + } + } + } + if (sticker->format_ == nullptr) { return Status::Error(400, "Sticker format must be non-empty"); } @@ -8018,8 +8029,13 @@ tl_object_ptr StickersManager::get_input_stic flags |= telegram_api::inputStickerSetItem::MASK_COORDS_MASK; } + string keywords = implode(sticker->keywords_, ','); + if (!keywords.empty()) { + flags |= telegram_api::inputStickerSetItem::KEYWORDS_MASK; + } + return make_tl_object(flags, std::move(input_document), sticker->emojis_, - std::move(mask_coords), string()); + std::move(mask_coords), keywords); } void StickersManager::get_suggested_sticker_set_name(string title, Promise &&promise) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 9f8303d6e..9930f8ff9 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2890,7 +2890,7 @@ class CliClient final : public Actor { } else if (op == "usf" || op == "usfa" || op == "usfv") { send_request(td_api::make_object( -1, td_api::make_object(as_input_file(args), "😀", as_sticker_format(op), - as_mask_position(op)))); + as_mask_position(op), Auto()))); } else if (op == "cnss" || op == "cnssa" || op == "cnssv" || op == "cnssm" || op == "cnsse") { string title; string name; @@ -2899,7 +2899,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_mask_position(op)); + as_mask_position(op), vector{"keyword"}); }); send_request(td_api::make_object(my_id_, title, name, as_sticker_type(op), false, std::move(input_stickers), "tg_cli"));