Return keywords in searchEmojis.
This commit is contained in:
parent
9e0bb80dcf
commit
bf6345248f
@ -3342,6 +3342,12 @@ userStatusLastWeek = UserStatus;
|
||||
userStatusLastMonth = UserStatus;
|
||||
|
||||
|
||||
//@description Represents an emoji with its keyword @emoji The emoji @keyword The keyword
|
||||
emojiKeyword emoji:string keyword:string = EmojiKeyword;
|
||||
|
||||
//@description Represents a list of emoji with their keywords @emoji_keywords List of emoji with their keywords
|
||||
emojiKeywords emoji_keywords:vector<emojiKeyword> = EmojiKeywords;
|
||||
|
||||
//@description Represents a list of stickers @stickers List of stickers
|
||||
stickers stickers:vector<sticker> = Stickers;
|
||||
|
||||
@ -8901,12 +8907,12 @@ removeFavoriteSticker sticker:InputFile = Ok;
|
||||
//@description Returns emoji corresponding to a sticker. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object @sticker Sticker file identifier
|
||||
getStickerEmojis sticker:InputFile = Emojis;
|
||||
|
||||
//@description Searches for emojis by keywords. Supported only if the file database is enabled
|
||||
//@description Searches for emojis by keywords. Supported only if the file database is enabled. Order of results is unspecified
|
||||
//@text Text to search for
|
||||
//@input_language_codes List of possible IETF language tags of the user's input language; may be empty if unknown
|
||||
searchEmojis text:string input_language_codes:vector<string> = Emojis;
|
||||
searchEmojis text:string input_language_codes:vector<string> = EmojiKeywords;
|
||||
|
||||
//@description Return emojis matching the keyword. Supported only if the file database is enabled
|
||||
//@description Return emojis matching the keyword. Supported only if the file database is enabled. Order of results is unspecified
|
||||
//@text Text to search for
|
||||
//@input_language_codes List of possible IETF language tags of the user's input language; may be empty if unknown
|
||||
getKeywordEmojis text:string input_language_codes:vector<string> = Emojis;
|
||||
|
@ -9478,13 +9478,14 @@ string StickersManager::get_language_emojis_database_key(const string &language_
|
||||
return PSTRING() << "emoji$" << language_code << '$' << text;
|
||||
}
|
||||
|
||||
vector<string> StickersManager::search_language_emojis(const string &language_code, const string &text) {
|
||||
vector<std::pair<string, string>> StickersManager::search_language_emojis(const string &language_code,
|
||||
const string &text) {
|
||||
LOG(INFO) << "Search emoji for \"" << text << "\" in language " << language_code;
|
||||
auto key = get_language_emojis_database_key(language_code, text);
|
||||
vector<string> result;
|
||||
G()->td_db()->get_sqlite_sync_pmc()->get_by_prefix(key, [&result](Slice key, Slice value) {
|
||||
for (auto &emoji : full_split(value, '$')) {
|
||||
result.push_back(emoji.str());
|
||||
vector<std::pair<string, string>> result;
|
||||
G()->td_db()->get_sqlite_sync_pmc()->get_by_prefix(key, [&text, &result](Slice key, Slice value) {
|
||||
for (const auto &emoji : full_split(value, '$')) {
|
||||
result.emplace_back(emoji.str(), PSTRING() << text << key);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@ -9889,14 +9890,15 @@ bool StickersManager::prepare_search_emoji_query(const string &text, const vecto
|
||||
return true;
|
||||
}
|
||||
|
||||
vector<string> StickersManager::search_emojis(const string &text, const vector<string> &input_language_codes,
|
||||
bool force, Promise<Unit> &&promise) {
|
||||
vector<std::pair<string, string>> StickersManager::search_emojis(const string &text,
|
||||
const vector<string> &input_language_codes, bool force,
|
||||
Promise<Unit> &&promise) {
|
||||
SearchEmojiQuery query;
|
||||
if (!prepare_search_emoji_query(text, input_language_codes, force, promise, query)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
vector<string> result;
|
||||
vector<std::pair<string, string>> result;
|
||||
for (auto &language_code : query.language_codes_) {
|
||||
combine(result, search_language_emojis(language_code, query.text_));
|
||||
}
|
||||
|
@ -373,8 +373,8 @@ class StickersManager final : public Actor {
|
||||
|
||||
vector<string> get_sticker_emojis(const tl_object_ptr<td_api::InputFile> &input_file, Promise<Unit> &&promise);
|
||||
|
||||
vector<string> search_emojis(const string &text, const vector<string> &input_language_codes, bool force,
|
||||
Promise<Unit> &&promise);
|
||||
vector<std::pair<string, string>> search_emojis(const string &text, const vector<string> &input_language_codes,
|
||||
bool force, Promise<Unit> &&promise);
|
||||
|
||||
vector<string> get_keyword_emojis(const string &text, const vector<string> &input_language_codes, bool force,
|
||||
Promise<Unit> &&promise);
|
||||
@ -950,7 +950,7 @@ class StickersManager final : public Actor {
|
||||
|
||||
void on_get_language_codes(const string &key, Result<vector<string>> &&result);
|
||||
|
||||
static vector<string> search_language_emojis(const string &language_code, const string &text);
|
||||
static vector<std::pair<string, string>> search_language_emojis(const string &language_code, const string &text);
|
||||
|
||||
static vector<string> get_keyword_language_emojis(const string &language_code, const string &text);
|
||||
|
||||
|
@ -2294,14 +2294,18 @@ class SearchEmojisRequest final : public RequestActor<> {
|
||||
string text_;
|
||||
vector<string> input_language_codes_;
|
||||
|
||||
vector<string> emojis_;
|
||||
vector<std::pair<string, string>> emoji_keywords_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
emojis_ = td_->stickers_manager_->search_emojis(text_, input_language_codes_, get_tries() < 2, std::move(promise));
|
||||
emoji_keywords_ =
|
||||
td_->stickers_manager_->search_emojis(text_, input_language_codes_, get_tries() < 2, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_api::make_object<td_api::emojis>(std::move(emojis_)));
|
||||
send_result(td_api::make_object<td_api::emojiKeywords>(
|
||||
transform(emoji_keywords_, [](const std::pair<string, string> &emoji_keyword) {
|
||||
return td_api::make_object<td_api::emojiKeyword>(emoji_keyword.first, emoji_keyword.second);
|
||||
})));
|
||||
}
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user