Add td_api::getAllAnimatedEmojis.

This commit is contained in:
levlam 2022-05-23 14:05:35 +03:00
parent 4e8e95c81c
commit e9a8d43a0a
6 changed files with 46 additions and 0 deletions

View File

@ -5764,6 +5764,9 @@ searchEmojis text:string exact_match:Bool input_language_codes:vector<string> =
//@description Returns an animated emoji corresponding to a given emoji. Returns a 404 error if the emoji has no animated emoji @emoji The emoji
getAnimatedEmoji emoji:string = AnimatedEmoji;
//@description Returns all emojis, which has a corresponding animated emoji
getAllAnimatedEmojis = Emojis;
//@description Returns an HTTP URL which can be used to automatically log in to the translation platform and suggest new emoji replacements. The URL will be valid for 30 seconds after generation @language_code Language code for which the emoji replacements will be suggested
getEmojiSuggestionsUrl language_code:string = HttpUrl;

View File

@ -4614,6 +4614,37 @@ void StickersManager::get_animated_emoji(string emoji, bool is_recursive,
get_animated_emoji_sound_file_id(emoji)));
}
void StickersManager::get_all_animated_emojis(bool is_recursive,
Promise<td_api::object_ptr<td_api::emojis>> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
auto &special_sticker_set = add_special_sticker_set(SpecialStickerSetType::animated_emoji());
auto sticker_set = get_sticker_set(special_sticker_set.id_);
if (sticker_set == nullptr || !sticker_set->was_loaded) {
if (is_recursive) {
return promise.set_value(td_api::make_object<td_api::emojis>());
}
pending_get_animated_emoji_queries_.push_back(PromiseCreator::lambda(
[actor_id = actor_id(this), promise = std::move(promise)](Result<Unit> &&result) mutable {
if (result.is_error()) {
promise.set_error(result.move_as_error());
} else {
send_closure(actor_id, &StickersManager::get_all_animated_emojis, true, std::move(promise));
}
}));
load_special_sticker_set(special_sticker_set);
return;
}
auto emojis = transform(sticker_set->sticker_ids, [&](FileId sticker_id) {
auto s = get_sticker(sticker_id);
CHECK(s != nullptr);
return s->alt;
});
promise.set_value(td_api::make_object<td_api::emojis>(std::move(emojis)));
}
void StickersManager::get_animated_emoji_click_sticker(const string &message_text, FullMessageId full_message_id,
Promise<td_api::object_ptr<td_api::sticker>> &&promise) {
if (disable_animated_emojis_ || td_->auth_manager_->is_bot()) {

View File

@ -83,6 +83,8 @@ class StickersManager final : public Actor {
void get_animated_emoji(string emoji, bool is_recursive,
Promise<td_api::object_ptr<td_api::animatedEmoji>> &&promise);
void get_all_animated_emojis(bool is_recursive, Promise<td_api::object_ptr<td_api::emojis>> &&promise);
void get_animated_emoji_click_sticker(const string &message_text, FullMessageId full_message_id,
Promise<td_api::object_ptr<td_api::sticker>> &&promise);

View File

@ -7113,6 +7113,12 @@ void Td::on_request(uint64 id, td_api::getAnimatedEmoji &request) {
stickers_manager_->get_animated_emoji(std::move(request.emoji_), false, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getAllAnimatedEmojis &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
stickers_manager_->get_all_animated_emojis(false, std::move(promise));
}
void Td::on_request(uint64 id, td_api::getEmojiSuggestionsUrl &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.language_code_);

View File

@ -1108,6 +1108,8 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::getAnimatedEmoji &request);
void on_request(uint64 id, const td_api::getAllAnimatedEmojis &request);
void on_request(uint64 id, td_api::getEmojiSuggestionsUrl &request);
void on_request(uint64 id, const td_api::getFavoriteStickers &request);

View File

@ -2737,6 +2737,8 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::searchEmojis>(args, false, vector<string>{"ru_RU"}));
} else if (op == "gae") {
send_request(td_api::make_object<td_api::getAnimatedEmoji>(args));
} else if (op == "gaae") {
send_request(td_api::make_object<td_api::getAllAnimatedEmojis>());
} else if (op == "gesu") {
send_request(td_api::make_object<td_api::getEmojiSuggestionsUrl>(args));
} else if (op == "gsan") {