Allow to pass multiple input language codes in searchEmojis.
GitOrigin-RevId: 0fb99694447f3ac02063eb9c03af2c2b3dfc267e
This commit is contained in:
parent
c96f62b34f
commit
52ea0998ec
@ -3956,8 +3956,8 @@ 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 @text Text to search for @exact_match True, if only emojis, which exactly match text needs to be returned @input_language_code IETF language tag of the user's input language; may be empty if unknown
|
||||
searchEmojis text:string exact_match:Bool input_language_code:string = Emojis;
|
||||
//@description Searches for emojis by keywords. Supported only if the file database is enabled @text Text to search for @exact_match True, if only emojis, which exactly match text needs to be returned @input_language_codes List of possible IETF language tags of the user's input language; may be empty if unknown
|
||||
searchEmojis text:string exact_match:Bool input_language_codes:vector<string> = 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;
|
||||
|
Binary file not shown.
@ -26981,7 +26981,7 @@ void MessagesManager::delete_message_from_database(Dialog *d, MessageId message_
|
||||
}
|
||||
}
|
||||
|
||||
if (m->random_id != 0 && (m->is_outgoing || d->dialog_id == get_my_dialog_id())) {
|
||||
if (m != nullptr && m->random_id != 0 && (m->is_outgoing || d->dialog_id == get_my_dialog_id())) {
|
||||
message_random_ids_.erase(m->random_id);
|
||||
}
|
||||
|
||||
|
@ -5770,15 +5770,17 @@ void StickersManager::on_get_language_codes(const string &key, Result<vector<str
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> StickersManager::get_emoji_language_codes(const string &input_language_code, Slice text,
|
||||
vector<string> StickersManager::get_emoji_language_codes(const vector<string> &input_language_codes, Slice text,
|
||||
Promise<Unit> &promise) {
|
||||
vector<string> language_codes = td_->language_pack_manager_->get_actor_unsafe()->get_used_language_codes();
|
||||
auto system_language_code = G()->mtproto_header().get_system_language_code();
|
||||
if (!system_language_code.empty() && system_language_code.find('$') == string::npos) {
|
||||
language_codes.push_back(system_language_code);
|
||||
}
|
||||
if (!input_language_code.empty() && input_language_code.find('$') == string::npos) {
|
||||
language_codes.push_back(input_language_code);
|
||||
for (auto &input_language_code : input_language_codes) {
|
||||
if (!input_language_code.empty() && input_language_code.find('$') == string::npos) {
|
||||
language_codes.push_back(input_language_code);
|
||||
}
|
||||
}
|
||||
if (!text.empty()) {
|
||||
uint32 code = 0;
|
||||
@ -6016,14 +6018,15 @@ void StickersManager::on_get_emoji_keywords_difference(
|
||||
emoji_language_code_last_difference_times_[language_code] = static_cast<int32>(Time::now_cached());
|
||||
}
|
||||
|
||||
vector<string> StickersManager::search_emojis(const string &text, bool exact_match, const string &input_language_code,
|
||||
bool force, Promise<Unit> &&promise) {
|
||||
vector<string> StickersManager::search_emojis(const string &text, bool exact_match,
|
||||
const vector<string> &input_language_codes, bool force,
|
||||
Promise<Unit> &&promise) {
|
||||
if (text.empty() || !G()->parameters().use_file_db /* have SQLite PMC */) {
|
||||
promise.set_value(Unit());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto language_codes = get_emoji_language_codes(input_language_code, text, promise);
|
||||
auto language_codes = get_emoji_language_codes(input_language_codes, text, promise);
|
||||
if (language_codes.empty()) {
|
||||
// promise was consumed
|
||||
return {};
|
||||
|
@ -228,8 +228,8 @@ class StickersManager : 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, bool exact_match, const string &input_language_code, bool force,
|
||||
Promise<Unit> &&promise);
|
||||
vector<string> search_emojis(const string &text, bool exact_match, const vector<string> &input_language_codes,
|
||||
bool force, Promise<Unit> &&promise);
|
||||
|
||||
int64 get_emoji_suggestions_url(const string &language_code, Promise<Unit> &&promise);
|
||||
|
||||
@ -591,7 +591,8 @@ class StickersManager : public Actor {
|
||||
|
||||
double get_emoji_language_code_last_difference_time(const string &language_code);
|
||||
|
||||
vector<string> get_emoji_language_codes(const string &input_language_code, Slice text, Promise<Unit> &promise);
|
||||
vector<string> get_emoji_language_codes(const vector<string> &input_language_codes, Slice text,
|
||||
Promise<Unit> &promise);
|
||||
|
||||
void load_language_codes(vector<string> language_codes, string key, Promise<Unit> &&promise);
|
||||
|
||||
|
@ -2714,12 +2714,12 @@ class GetStickerEmojisRequest : public RequestActor<> {
|
||||
class SearchEmojisRequest : public RequestActor<> {
|
||||
string text_;
|
||||
bool exact_match_;
|
||||
string input_language_code_;
|
||||
vector<string> input_language_codes_;
|
||||
|
||||
vector<string> emojis_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) override {
|
||||
emojis_ = td->stickers_manager_->search_emojis(text_, exact_match_, input_language_code_, get_tries() < 2,
|
||||
emojis_ = td->stickers_manager_->search_emojis(text_, exact_match_, input_language_codes_, get_tries() < 2,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
@ -2729,11 +2729,11 @@ class SearchEmojisRequest : public RequestActor<> {
|
||||
|
||||
public:
|
||||
SearchEmojisRequest(ActorShared<Td> td, uint64 request_id, string &&text, bool exact_match,
|
||||
string &&input_language_code)
|
||||
vector<string> &&input_language_codes)
|
||||
: RequestActor(std::move(td), request_id)
|
||||
, text_(std::move(text))
|
||||
, exact_match_(exact_match)
|
||||
, input_language_code_(std::move(input_language_code)) {
|
||||
, input_language_codes_(std::move(input_language_codes)) {
|
||||
set_tries(3);
|
||||
}
|
||||
};
|
||||
@ -6449,9 +6449,11 @@ void Td::on_request(uint64 id, td_api::getStickerEmojis &request) {
|
||||
void Td::on_request(uint64 id, td_api::searchEmojis &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.text_);
|
||||
CLEAN_INPUT_STRING(request.input_language_code_);
|
||||
for (auto &input_language_code : request.input_language_codes_) {
|
||||
CLEAN_INPUT_STRING(input_language_code);
|
||||
}
|
||||
CREATE_REQUEST(SearchEmojisRequest, std::move(request.text_), request.exact_match_,
|
||||
std::move(request.input_language_code_));
|
||||
std::move(request.input_language_codes_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getEmojiSuggestionsUrl &request) {
|
||||
|
@ -2405,11 +2405,11 @@ class CliClient final : public Actor {
|
||||
} else if (op == "gse") {
|
||||
send_request(td_api::make_object<td_api::getStickerEmojis>(as_input_file_id(args)));
|
||||
} else if (op == "se") {
|
||||
send_request(td_api::make_object<td_api::searchEmojis>(args, false, ""));
|
||||
send_request(td_api::make_object<td_api::searchEmojis>(args, false, vector<string>()));
|
||||
} else if (op == "see") {
|
||||
send_request(td_api::make_object<td_api::searchEmojis>(args, true, ""));
|
||||
send_request(td_api::make_object<td_api::searchEmojis>(args, true, vector<string>()));
|
||||
} else if (op == "seru") {
|
||||
send_request(td_api::make_object<td_api::searchEmojis>(args, false, "ru_RU"));
|
||||
send_request(td_api::make_object<td_api::searchEmojis>(args, false, vector<string>{"ru_RU"}));
|
||||
} else if (op == "gesu") {
|
||||
send_request(td_api::make_object<td_api::getEmojiSuggestionsUrl>(args));
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user