Add td_api::setStickerKeywords.

This commit is contained in:
levlam 2023-02-09 21:43:38 +03:00
parent c53b05e4e8
commit 8e74b99e13
5 changed files with 38 additions and 3 deletions

View File

@ -8020,11 +8020,16 @@ setStickerPositionInSet sticker:InputFile position:int32 = Ok;
//@description Removes a sticker from the set to which it belongs; for bots only. The sticker set must have been created by the bot @sticker Sticker
removeStickerFromSet sticker:InputFile = Ok;
//@description Changes the list of emoji corresponding to a sticker; for bots only. The sticker must belong to a sticker set created by the bot
//@description Changes the list of emoji corresponding to a sticker; for bots only. The sticker must belong to a regular or custom emoji sticker set created by the bot
//@sticker Sticker
//@emojis New string with 1-20 emoji corresponding to the sticker
setStickerEmojis sticker:InputFile emojis:string = Ok;
//@description Changes the list of keywords of a sticker; for bots only. The sticker must belong to a regular or custom emoji sticker set created by the bot
//@sticker Sticker
//@keywords List of up to 20 keywords with total length up to 64 characters, which can be used to find the sticker
setStickerKeywords sticker:InputFile keywords:vector<string> = Ok;
//@description Returns information about a file with a map thumbnail in PNG format. Only map thumbnail files with size less than 1MB can be downloaded
//@location Location of the map center

View File

@ -1412,8 +1412,8 @@ class ChangeStickerQuery final : public Td::ResultHandler {
flags |= telegram_api::stickers_changeSticker::KEYWORDS_MASK;
}
send_query(G()->net_query_creator().create(
telegram_api::stickers_changeSticker(flags, std::move(input_document), emojis, mask_position.get_input_mask_coords(),
keywords),
telegram_api::stickers_changeSticker(flags, std::move(input_document), emojis,
mask_position.get_input_mask_coords(), keywords),
std::move(chain_ids)));
}
@ -8701,6 +8701,22 @@ void StickersManager::set_sticker_emojis(const td_api::object_ptr<td_api::InputF
StickerMaskPosition(), false, string());
}
void StickersManager::set_sticker_keywords(const td_api::object_ptr<td_api::InputFile> &sticker,
vector<string> &&keywords, Promise<Unit> &&promise) {
TRY_RESULT_PROMISE(promise, input_document, get_sticker_input_document(sticker));
for (auto &keyword : keywords) {
for (auto &c : keyword) {
if (c == ',' || c == '\n') {
c = ' ';
}
}
}
td_->create_handler<ChangeStickerQuery>(std::move(promise))
->send(input_document.sticker_set_short_name_, std::move(input_document.input_document_), false, string(), false,
StickerMaskPosition(), true, implode(keywords, ','));
}
vector<FileId> StickersManager::get_attached_sticker_file_ids(const vector<int32> &int_file_ids) {
vector<FileId> result;

View File

@ -319,6 +319,9 @@ class StickersManager final : public Actor {
void set_sticker_emojis(const td_api::object_ptr<td_api::InputFile> &sticker, const string &emojis,
Promise<Unit> &&promise);
void set_sticker_keywords(const td_api::object_ptr<td_api::InputFile> &sticker, vector<string> &&keywords,
Promise<Unit> &&promise);
vector<FileId> get_recent_stickers(bool is_attached, Promise<Unit> &&promise);
void on_get_recent_stickers(bool is_repair, bool is_attached,

View File

@ -7345,6 +7345,15 @@ void Td::on_request(uint64 id, td_api::setStickerEmojis &request) {
stickers_manager_->set_sticker_emojis(request.sticker_, request.emojis_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::setStickerKeywords &request) {
CHECK_IS_BOT();
for (auto &keyword : request.keywords_) {
CLEAN_INPUT_STRING(keyword);
}
CREATE_OK_REQUEST_PROMISE();
stickers_manager_->set_sticker_keywords(request.sticker_, std::move(request.keywords_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getRecentStickers &request) {
CHECK_IS_USER();
CREATE_REQUEST(GetRecentStickersRequest, request.is_attached_);

View File

@ -1210,6 +1210,8 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::setStickerEmojis &request);
void on_request(uint64 id, td_api::setStickerKeywords &request);
void on_request(uint64 id, const td_api::getRecentStickers &request);
void on_request(uint64 id, td_api::addRecentSticker &request);