Add synchronous td_api::getCountryFlagEmoji.
This commit is contained in:
parent
a9d1269567
commit
0b5b4b8dab
@ -3978,7 +3978,7 @@ availableReaction type:ReactionType needs_premium:Bool = AvailableReaction;
|
||||
//@allow_custom_emoji True, if any custom emoji reaction can be added by Telegram Premium subscribers
|
||||
availableReactions top_reactions:vector<availableReaction> recent_reactions:vector<availableReaction> popular_reactions:vector<availableReaction> allow_custom_emoji:Bool = AvailableReactions;
|
||||
|
||||
//@description Contains information about a emoji reaction
|
||||
//@description Contains information about an emoji reaction
|
||||
//@emoji Text representation of the reaction
|
||||
//@title Reaction title
|
||||
//@is_active True, if the reaction can be added to new messages and enabled in chats
|
||||
@ -7520,7 +7520,7 @@ setPinnedForumTopics chat_id:int53 message_thread_ids:vector<int53> = Ok;
|
||||
deleteForumTopic chat_id:int53 message_thread_id:int53 = Ok;
|
||||
|
||||
|
||||
//@description Returns information about a emoji reaction. Returns a 404 error if the reaction is not found @emoji Text representation of the reaction
|
||||
//@description Returns information about an emoji reaction. Returns a 404 error if the reaction is not found @emoji Text representation of the reaction
|
||||
getEmojiReaction emoji:string = EmojiReaction;
|
||||
|
||||
//@description Returns TGS stickers with generic animations for custom emoji reactions
|
||||
@ -7587,6 +7587,9 @@ parseMarkdown text:formattedText = FormattedText;
|
||||
//@description Replaces text entities with Markdown formatting in a human-friendly format. Entities that can't be represented in Markdown unambiguously are kept as is. Can be called synchronously @text The text
|
||||
getMarkdownText text:formattedText = FormattedText;
|
||||
|
||||
//@description Returns an emoji for the given country. Returns an empty string on failure. Can be called synchronously @country_code A two-letter ISO 3166-1 alpha-2 country code as received from getCountries
|
||||
getCountryFlagEmoji country_code:string = Text;
|
||||
|
||||
//@description Returns the MIME type of a file, guessed by its extension. Returns an empty string on failure. Can be called synchronously @file_name The name of the file or path to the file
|
||||
getFileMimeType file_name:string = Text;
|
||||
|
||||
|
@ -577,6 +577,32 @@ const CountryInfoManager::CountryList *CountryInfoManager::get_country_list(Coun
|
||||
return country;
|
||||
}
|
||||
|
||||
string CountryInfoManager::get_country_flag_emoji(const string &country_code) {
|
||||
if (country_code.size() != 2 || !is_alpha(country_code[0]) || !is_alpha(country_code[1])) {
|
||||
return string();
|
||||
}
|
||||
char first = to_upper(country_code[0]);
|
||||
char second = to_upper(country_code[1]);
|
||||
if (first == 'Y' && second == 'L') {
|
||||
return string();
|
||||
}
|
||||
if (first == 'F' && second == 'T') {
|
||||
return "\xF0\x9F\x8F\xB4\xE2\x80\x8D\xE2\x98\xA0\xEF\xB8\x8F"; // pirate flag
|
||||
}
|
||||
if (first == 'X' && second == 'G') {
|
||||
return "\xF0\x9F\x9B\xB0"; // satellite
|
||||
}
|
||||
if (first == 'X' && second == 'V') {
|
||||
return "\xF0\x9F\x8C\x8D"; // globe showing Europe-Africa
|
||||
}
|
||||
string result;
|
||||
result.reserve(8);
|
||||
append_utf8_character(result, 0x1F1A5 + first);
|
||||
append_utf8_character(result, 0x1F1A5 + second);
|
||||
CHECK(result.size() == 8);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32 CountryInfoManager::manager_count_ = 0;
|
||||
std::mutex CountryInfoManager::country_mutex_;
|
||||
FlatHashMap<string, unique_ptr<CountryInfoManager::CountryList>> CountryInfoManager::countries_;
|
||||
|
@ -37,6 +37,8 @@ class CountryInfoManager final : public Actor {
|
||||
static td_api::object_ptr<td_api::phoneNumberInfo> get_phone_number_info_sync(const string &language_code,
|
||||
string phone_number_prefix);
|
||||
|
||||
static string get_country_flag_emoji(const string &country_code);
|
||||
|
||||
void on_update_fragment_prefixes();
|
||||
|
||||
CountryInfoManager(const CountryInfoManager &) = delete;
|
||||
|
@ -2740,6 +2740,7 @@ bool Td::is_synchronous_request(const td_api::Function *function) {
|
||||
case td_api::parseMarkdown::ID:
|
||||
case td_api::getMarkdownText::ID:
|
||||
case td_api::searchStringsByPrefix::ID:
|
||||
case td_api::getCountryFlagEmoji::ID:
|
||||
case td_api::getFileMimeType::ID:
|
||||
case td_api::getFileExtension::ID:
|
||||
case td_api::cleanFileName::ID:
|
||||
@ -2980,6 +2981,7 @@ td_api::object_ptr<td_api::Object> Td::static_request(td_api::object_ptr<td_api:
|
||||
case td_api::parseMarkdown::ID:
|
||||
case td_api::getMarkdownText::ID:
|
||||
case td_api::searchStringsByPrefix::ID:
|
||||
case td_api::getCountryFlagEmoji::ID:
|
||||
case td_api::getFileMimeType::ID:
|
||||
case td_api::getFileExtension::ID:
|
||||
case td_api::cleanFileName::ID:
|
||||
@ -9042,6 +9044,10 @@ void Td::on_request(uint64 id, const td_api::searchStringsByPrefix &request) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getCountryFlagEmoji &request) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getFileMimeType &request) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -9246,6 +9252,11 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::searchStringsBy
|
||||
return td_api::make_object<td_api::foundPositions>(total_count, std::move(result));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getCountryFlagEmoji &request) {
|
||||
// don't check country code UTF-8 correctness
|
||||
return td_api::make_object<td_api::text>(CountryInfoManager::get_country_flag_emoji(request.country_code_));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getFileMimeType &request) {
|
||||
// don't check file name UTF-8 correctness
|
||||
return make_tl_object<td_api::text>(MimeType::from_extension(PathView(request.file_name_).extension()));
|
||||
|
@ -1731,6 +1731,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::searchStringsByPrefix &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getCountryFlagEmoji &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getFileMimeType &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getFileExtension &request);
|
||||
@ -1793,6 +1795,7 @@ class Td final : public Actor {
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(td_api::parseMarkdown &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(td_api::getMarkdownText &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(td_api::searchStringsByPrefix &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::getCountryFlagEmoji &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::getFileMimeType &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::getFileExtension &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::cleanFileName &request);
|
||||
|
@ -4133,6 +4133,8 @@ class CliClient final : public Actor {
|
||||
get_args(args, strings, query, limit, return_none_for_empty_query);
|
||||
execute(td_api::make_object<td_api::searchStringsByPrefix>(autosplit_str(strings), query, as_limit(limit),
|
||||
return_none_for_empty_query));
|
||||
} else if (op == "gcfe") {
|
||||
execute(td_api::make_object<td_api::getCountryFlagEmoji>(trim(args)));
|
||||
} else if (op == "gfmt") {
|
||||
execute(td_api::make_object<td_api::getFileMimeType>(trim(args)));
|
||||
} else if (op == "gfe") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user