From fc3a8105a3d24aefff5afcf9072312759f44663b Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 19 Apr 2020 11:17:51 +0300 Subject: [PATCH] Add updateDiceEmojis. GitOrigin-RevId: 8495528763939fda21e04eac8555aaed975ded62 --- td/generate/scheme/td_api.tl | 5 ++++- td/generate/scheme/td_api.tlo | Bin 171156 -> 171268 bytes td/telegram/ConfigManager.cpp | 30 ++++++++++++++++++++++++++++++ td/telegram/StickersManager.cpp | 18 ++++++++++++++++++ td/telegram/StickersManager.h | 6 ++++++ td/telegram/Td.cpp | 5 ++++- 6 files changed, 62 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 20397f74b..9ea7e5ebf 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 e9f8a1b1e8fe0ab933f67255a9aab9fe5f063b23..17d799cb2560801643bed3074685feacc031d4a3 100644 GIT binary patch delta 1971 zcmZuyUuaWj6z}=0l7$YhA~bB5trGNgW8)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lfw%RT1sMSkdsy!NBa=VYZ|f)p_wE*QkI!vbBgl^Qrx3jE2_{w%!{oKOOi~( zFth`)e1F1j*9aUVEIh(oi4k6RXPOlR(vYS&+bCn5S40iE8$>xdlA|o)%_sz%g)3Af zfA4pc)ctT>KVEX#xXh<6oo_5MuI{lhF4{cC*|9M`&>UmY3`4#QhlNb6+r;z?-(tr& zcjzC7dJ;HpVr@4>B|0XUw044n?FWPdW2PfF0S@ym04;v4TvIFLih3qFscsTdRKY&Q zm^vkQ5nHFgLEfGzZuSjZ(VHSb&fqk7%u;K#O(*uCzaN~pyv3NGW}(Vcp1u8o@S<%a zIL#>iDfAFk=o!BS`3TeJp2@jIpEH^7Ig9lNMVL}oOsrJr2C8)~s(%JACUkynS51dK z%Xhji%fangeiw3COKSqN+r%DJ-LMu9&A@J|TR+2Ex@Wiz->l^!2K?FxW!N?gTPUO3 z>J@nSBUE5u`ybL@vrs`H-Z|ct;2djFUPygf;Fh9w9<^h`3+STw;(3eCwc6XS6<9yd zYHTmf#DgxZdkN!|q%6oowGz6pX947mRTeo>KO!qGLK`K2S(I&OcD({cUe2l|9%20w zFH8?(TC7jO{1QJWzGb;wTJ &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 491b686d3..f9ae0950a 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 0299aa713..db86769e8 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: