Support inputSticker keywords.

This commit is contained in:
levlam 2023-02-09 15:23:55 +03:00
parent 8e2cbeebc1
commit b6de7319d4
3 changed files with 23 additions and 6 deletions

View File

@ -5023,12 +5023,13 @@ proxies proxies:vector<proxy> = 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<string> = 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

View File

@ -7919,6 +7919,17 @@ Result<std::tuple<FileId, bool, bool, StickerFormat>> 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<telegram_api::inputStickerSetItem> 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<telegram_api::inputStickerSetItem>(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<string> &&promise) {

View File

@ -2890,7 +2890,7 @@ class CliClient final : public Actor {
} else if (op == "usf" || op == "usfa" || op == "usfv") {
send_request(td_api::make_object<td_api::uploadStickerFile>(
-1, td_api::make_object<td_api::inputSticker>(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<td_api::inputSticker> {
return td_api::make_object<td_api::inputSticker>(as_input_file(sticker), "😀", as_sticker_format(op),
as_mask_position(op));
as_mask_position(op), vector<string>{"keyword"});
});
send_request(td_api::make_object<td_api::createNewStickerSet>(my_id_, title, name, as_sticker_type(op), false,
std::move(input_stickers), "tg_cli"));