Allow mutiple emojis in searchStickers.

This commit is contained in:
levlam 2023-01-23 21:40:32 +03:00
parent e5441b5ed7
commit 833c7c30da
3 changed files with 14 additions and 9 deletions

View File

@ -7216,11 +7216,11 @@ getUserProfilePhotos user_id:int53 offset:int32 limit:int32 = ChatPhotos;
//@chat_id Chat identifier for which to return stickers. Available custom emoji stickers may be different for different chats
getStickers sticker_type:StickerType query:string limit:int32 chat_id:int53 = Stickers;
//@description Searches for stickers from public sticker sets that correspond to a given emoji
//@description Searches for stickers from public sticker sets that correspond to one of the given emoji
//@sticker_type Type of the stickers to return
//@emoji String representation of emoji; must be non-empty
//@emojis Concatenated list of emoji to search for; must be non-empty
//@limit The maximum number of stickers to be returned; 0-100
searchStickers sticker_type:StickerType emoji:string limit:int32 = Stickers;
searchStickers sticker_type:StickerType emojis:string limit:int32 = Stickers;
//@description Returns premium stickers from regular sticker sets @limit The maximum number of stickers to be returned; 0-100
getPremiumStickers limit:int32 = Stickers;

View File

@ -4749,9 +4749,6 @@ void StickersManager::search_stickers(StickerType sticker_type, string emoji, in
if (limit > MAX_FOUND_STICKERS) {
limit = MAX_FOUND_STICKERS;
}
if (emoji.empty()) {
return promise.set_error(Status::Error(400, "Emoji must be non-empty"));
}
remove_emoji_modifiers_in_place(emoji);
if (emoji.empty() || sticker_type == StickerType::Mask) {

View File

@ -7147,10 +7147,18 @@ void Td::on_request(uint64 id, td_api::getStickers &request) {
void Td::on_request(uint64 id, td_api::searchStickers &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.emoji_);
CLEAN_INPUT_STRING(request.emojis_);
CREATE_REQUEST_PROMISE();
stickers_manager_->search_stickers(get_sticker_type(request.sticker_type_), std::move(request.emoji_), request.limit_,
std::move(promise));
auto sticker_type = get_sticker_type(request.sticker_type_);
if (sticker_type == StickerType::Regular) {
// legacy
if (request.emojis_ == "⭐️⭐️") {
request.emojis_ == "⭐️";
} else if (request.emojis_ == "📂⭐️") {
request.emojis_ == "📂";
}
}
stickers_manager_->search_stickers(sticker_type, std::move(request.emojis_), request.limit_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getPremiumStickers &request) {