Add "themed_premium_statuses_sticker_set_id" option.

This commit is contained in:
levlam 2022-08-31 19:03:26 +03:00
parent 1890d45680
commit 4370e88352
6 changed files with 26 additions and 4 deletions

View File

@ -475,7 +475,7 @@ chatAdministratorRights can_manage_chat:Bool can_change_info:Bool can_post_messa
//@payment_link An internal link to be opened for buying Telegram Premium to the user if store payment isn't possible; may be null if direct payment isn't available
premiumPaymentOption currency:string amount:int53 discount_percentage:int32 month_count:int32 store_product_id:string payment_link:InternalLinkType = PremiumPaymentOption;
//@description Describes a custom emoji to be shown instead of the Telegram Premium badge @custom_emoji_id Identifier of the custom emoji in stickerFormatTgs format
//@description Describes a custom emoji to be shown instead of the Telegram Premium badge @custom_emoji_id Identifier of the custom emoji in stickerFormatTgs format. If the custom emoji belongs to the sticker set GetOption("themed_premium_statuses_sticker_set_id"), then it's color must be changed to the color of the Telegram Premium badge
premiumStatus custom_emoji_id:int64 = PremiumStatus;
//@description Contains a list of premium statuses @premium_statuses The list of premium statuses

View File

@ -1478,10 +1478,10 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
string animation_search_emojis;
vector<SuggestedAction> suggested_actions;
bool can_archive_and_mute_new_chats_from_unknown_users = false;
int64 chat_read_mark_expire_period = 0;
int64 chat_read_mark_size_threshold = 0;
int32 chat_read_mark_expire_period = 0;
int32 chat_read_mark_size_threshold = 0;
double animated_emoji_zoom = 0.0;
int64 reactions_uniq_max = 0;
int32 reactions_uniq_max = 0;
vector<string> premium_features;
auto &premium_limit_keys = get_premium_limit_keys();
string premium_bot_username;
@ -1801,6 +1801,11 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
stickers_normal_by_emoji_per_premium_num = get_json_value_int(std::move(key_value->value_), key);
continue;
}
if (key == "default_emoji_statuses_stickerset_id") {
auto setting_value = get_json_value_long(std::move(key_value->value_), key);
G()->set_option_integer("themed_premium_statuses_sticker_set_id", setting_value);
continue;
}
new_values.push_back(std::move(key_value));
}

View File

@ -700,6 +700,7 @@ class UpdateEmojiStatusQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
get_recent_emoji_statuses(td_, Auto());
promise_.set_error(std::move(status));
}
};

View File

@ -217,6 +217,15 @@ int32 get_json_value_int(telegram_api::object_ptr<telegram_api::JSONValue> &&jso
return 0;
}
int64 get_json_value_long(telegram_api::object_ptr<telegram_api::JSONValue> &&json_value, Slice name) {
CHECK(json_value != nullptr);
if (json_value->get_id() == telegram_api::jsonString::ID) {
return to_integer<int64>(static_cast<const telegram_api::jsonString *>(json_value.get())->value_);
}
LOG(ERROR) << "Expected Long as " << name << ", but found " << to_string(json_value);
return 0;
}
double get_json_value_double(telegram_api::object_ptr<telegram_api::JSONValue> &&json_value, Slice name) {
CHECK(json_value != nullptr);
if (json_value->get_id() == telegram_api::jsonNumber::ID) {

View File

@ -30,6 +30,8 @@ bool get_json_value_bool(telegram_api::object_ptr<telegram_api::JSONValue> &&jso
int32 get_json_value_int(telegram_api::object_ptr<telegram_api::JSONValue> &&json_value, Slice name);
int64 get_json_value_long(telegram_api::object_ptr<telegram_api::JSONValue> &&json_value, Slice name);
double get_json_value_double(telegram_api::object_ptr<telegram_api::JSONValue> &&json_value, Slice name);
string get_json_value_string(telegram_api::object_ptr<telegram_api::JSONValue> &&json_value, Slice name);

View File

@ -102,6 +102,11 @@ OptionManager::OptionManager(Td *td)
if (!have_option("chat_filter_chosen_chat_count_max")) {
set_option_integer("chat_filter_chosen_chat_count_max", G()->is_test_dc() ? 5 : 100);
}
if (!have_option("themed_premium_statuses_sticker_set_id")) {
auto sticker_set_id =
G()->is_test_dc() ? static_cast<int64>(2964141614563343) : static_cast<int64>(773947703670341676);
set_option_integer("themed_premium_statuses_sticker_set_id", sticker_set_id);
}
}
OptionManager::~OptionManager() = default;