Add updateDiceEmojis.

GitOrigin-RevId: 8495528763939fda21e04eac8555aaed975ded62
This commit is contained in:
levlam 2020-04-19 11:17:51 +03:00
parent d27bf642eb
commit fc3a8105a3
6 changed files with 62 additions and 2 deletions

View File

@ -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<chatNearby> = Update;
//@description The list of supported dice emojis has changed @emojis The new list of supported dice emojis
updateDiceEmojis emojis:vector<string> = 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;

Binary file not shown.

View File

@ -1291,6 +1291,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &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<telegram_api::jsonObject *>(config.get())->value_) {
Slice key = key_value->key_;
@ -1318,6 +1319,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
if (value->get_id() == telegram_api::jsonArray::ID) {
auto reasons = std::move(static_cast<telegram_api::jsonArray *>(value)->value_);
for (auto &reason : reasons) {
CHECK(reason != nullptr);
if (reason->get_id() == telegram_api::jsonString::ID) {
Slice reason_name = static_cast<telegram_api::jsonString *>(reason.get())->value_;
if (!reason_name.empty() && reason_name.find(',') == Slice::npos) {
@ -1337,6 +1339,30 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
}
continue;
}
if (key == "emojies_send_dice") {
if (value->get_id() == telegram_api::jsonArray::ID) {
auto emojis = std::move(static_cast<telegram_api::jsonArray *>(value)->value_);
for (auto &emoji : emojis) {
CHECK(emoji != nullptr);
if (emoji->get_id() == telegram_api::jsonString::ID) {
Slice emoji_text = static_cast<telegram_api::jsonString *>(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<telegram_api::JSONValue> &c
get_content_settings(Auto());
}
}
if (!dice_emojis.empty()) {
shared_config.set_option_string("dice_emojis", dice_emojis);
}
}
} // namespace td

View File

@ -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<td_api::updateDiceEmojis> StickersManager::get_update_dice_emojis_object() const {
return td_api::make_object<td_api::updateDiceEmojis>(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<td_api::object_ptr<td_api::Update
if (are_favorite_stickers_loaded_) {
updates.push_back(get_update_favorite_stickers_object());
}
if (!dice_emojis_.empty()) {
updates.push_back(get_update_dice_emojis_object());
}
}
} // namespace td

View File

@ -121,6 +121,8 @@ class StickersManager : public Actor {
void on_uninstall_sticker_set(StickerSetId set_id);
void on_update_dice_emojis();
void on_update_sticker_sets();
void on_update_sticker_sets_order(bool is_masks, const vector<StickerSetId> &sticker_set_ids);
@ -540,6 +542,8 @@ class StickersManager : public Actor {
bool update_sticker_set_cache(const StickerSet *sticker_set, Promise<Unit> &promise);
td_api::object_ptr<td_api::updateDiceEmojis> 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<string, vector<Promise<Unit>>> load_emoji_keywords_queries_;
std::unordered_map<string, vector<Promise<Unit>>> load_language_codes_queries_;
std::unordered_map<int64, string> emoji_suggestions_urls_;
string dice_emojis_;
};
} // namespace td

View File

@ -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<td_api::Update> &&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: