diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 20397f74..9ea7e5eb 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3040,9 +3040,12 @@ updateConnectionState state:ConnectionState = Update; //@description New terms of service must be accepted by the user. If the terms of service are declined, then the deleteAccount method should be called with the reason "Decline ToS update" @terms_of_service_id Identifier of the terms of service @terms_of_service The new terms of service updateTermsOfService terms_of_service_id:string terms_of_service:termsOfService = Update; -//@description List of users nearby has changed. The update is sent only 60 seconds after a successful searchChatsNearby request @users_nearby The new list of users nearby +//@description The list of users nearby has changed. The update is sent only 60 seconds after a successful searchChatsNearby request @users_nearby The new list of users nearby updateUsersNearby users_nearby:vector = Update; +//@description The list of supported dice emojis has changed @emojis The new list of supported dice emojis +updateDiceEmojis emojis:vector = Update; + //@description A new incoming inline query; for bots only @id Unique query identifier @sender_user_id Identifier of the user who sent the query @user_location User location, provided by the client; may be null //@query Text of the query @offset Offset of the first entry to return updateNewInlineQuery id:int64 sender_user_id:int32 user_location:location query:string offset:string = Update; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index e9f8a1b1..17d799cb 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 4f987aab..83a8d0d1 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -1291,6 +1291,7 @@ void ConfigManager::process_app_config(tl_object_ptr &c string wallet_blockchain_name; string wallet_config; string ignored_restriction_reasons; + string dice_emojis; if (config->get_id() == telegram_api::jsonObject::ID) { for (auto &key_value : static_cast(config.get())->value_) { Slice key = key_value->key_; @@ -1318,6 +1319,7 @@ void ConfigManager::process_app_config(tl_object_ptr &c if (value->get_id() == telegram_api::jsonArray::ID) { auto reasons = std::move(static_cast(value)->value_); for (auto &reason : reasons) { + CHECK(reason != nullptr); if (reason->get_id() == telegram_api::jsonString::ID) { Slice reason_name = static_cast(reason.get())->value_; if (!reason_name.empty() && reason_name.find(',') == Slice::npos) { @@ -1337,6 +1339,30 @@ void ConfigManager::process_app_config(tl_object_ptr &c } continue; } + if (key == "emojies_send_dice") { + if (value->get_id() == telegram_api::jsonArray::ID) { + auto emojis = std::move(static_cast(value)->value_); + for (auto &emoji : emojis) { + CHECK(emoji != nullptr); + if (emoji->get_id() == telegram_api::jsonString::ID) { + Slice emoji_text = static_cast(emoji.get())->value_; + if (!emoji_text.empty()) { + if (!dice_emojis.empty()) { + dice_emojis += '\x01'; + } + dice_emojis.append(emoji_text.begin(), emoji_text.end()); + } else { + LOG(ERROR) << "Receive empty dice emoji"; + } + } else { + LOG(ERROR) << "Receive unexpected dice emoji " << to_string(emoji); + } + } + } else { + LOG(ERROR) << "Receive unexpected emojies_send_dice " << to_string(*value); + } + continue; + } new_values.push_back(std::move(key_value)); } @@ -1367,6 +1393,10 @@ void ConfigManager::process_app_config(tl_object_ptr &c get_content_settings(Auto()); } } + + if (!dice_emojis.empty()) { + shared_config.set_option_string("dice_emojis", dice_emojis); + } } } // namespace td diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 491b686d..f9ae0950 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1138,6 +1138,7 @@ StickersManager::StickersManager(Td *td, ActorShared<> parent) : td_(td), parent on_update_recent_stickers_limit(G()->shared_config().get_option_integer("recent_stickers_limit", 200)); on_update_favorite_stickers_limit(G()->shared_config().get_option_integer("favorite_stickers_limit", 5)); + on_update_dice_emojis(); } void StickersManager::start_up() { @@ -3245,6 +3246,20 @@ void StickersManager::on_uninstall_sticker_set(StickerSetId set_id) { send_update_installed_sticker_sets(); } +td_api::object_ptr StickersManager::get_update_dice_emojis_object() const { + return td_api::make_object(full_split(dice_emojis_, '\x01')); +} + +void StickersManager::on_update_dice_emojis() { + auto dice_emojis = G()->shared_config().get_option_string("dice_emojis", "🎲\x01🎯"); + if (dice_emojis == dice_emojis_) { + return; + } + dice_emojis_ = std::move(dice_emojis); + + send_closure(G()->td(), &Td::send_update, get_update_dice_emojis_object()); +} + void StickersManager::on_update_sticker_sets() { // TODO better support archived_sticker_set_ids_[0].clear(); @@ -5930,6 +5945,9 @@ void StickersManager::get_current_state(vector &sticker_set_ids); @@ -540,6 +542,8 @@ class StickersManager : public Actor { bool update_sticker_set_cache(const StickerSet *sticker_set, Promise &promise); + td_api::object_ptr get_update_dice_emojis_object() const; + void start_up() override; void tear_down() override; @@ -684,6 +688,8 @@ class StickersManager : public Actor { std::unordered_map>> load_emoji_keywords_queries_; std::unordered_map>> load_language_codes_queries_; std::unordered_map emoji_suggestions_urls_; + + string dice_emojis_; }; } // namespace td diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 0299aa71..db86769e 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -3457,7 +3457,7 @@ bool Td::is_internal_config_option(Slice name) { return name == "call_ring_timeout_ms" || name == "call_receive_timeout_ms" || name == "channels_read_media_period"; case 'd': - return name == "dc_txt_domain_name"; + return name == "dc_txt_domain_name" || name == "dice_emojis"; case 'e': return name == "edit_time_limit"; case 'i': @@ -3544,6 +3544,8 @@ void Td::on_config_option_updated(const string &name) { return send_closure(notification_manager_actor_, &NotificationManager::on_notification_default_delay_changed); } else if (name == "ignored_restriction_reasons") { return send_closure(contacts_manager_actor_, &ContactsManager::on_ignored_restriction_reasons_changed); + } else if (name == "dice_emojis") { + return send_closure(stickers_manager_actor_, &StickersManager::on_update_dice_emojis); } else if (is_internal_config_option(name)) { return; } @@ -4351,6 +4353,7 @@ void Td::send_update(tl_object_ptr &&object) { case td_api::updateUnreadChatCount::ID / 2: case td_api::updateChatOnlineMemberCount::ID / 2: case td_api::updateUserChatAction::ID / 2: + case td_api::updateDiceEmojis::ID / 2: LOG(ERROR) << "Sending update: " << oneline(to_string(object)); break; default: