From 6ec7ab73e507092f1fe51bdbb3b54e062dd98dd3 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 18 Oct 2023 18:28:55 +0300 Subject: [PATCH] Add "giveaway_duration_max" option. --- td/generate/scheme/td_api.tl | 2 +- td/telegram/ConfigManager.cpp | 4 ++++ td/telegram/ConfigManager.h | 2 +- td/telegram/OptionManager.cpp | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 45f5ce96a..ba57511de 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2312,7 +2312,7 @@ messageExtendedMediaUnsupported caption:formattedText = MessageExtendedMedia; //@description Describes parameters of a Telegram Premium giveaway //@boosted_chat_id Identifier of the channel chat, which will be automatically boosted by the winners of the giveaway for duration of the Premium subscription //@additional_chat_ids Identifiers of other channel chats that must be subscribed by the users to be eligible for the giveaway. There can be up to getOption("giveaway_additional_chat_count_max") additional chats -//@winners_selection_date Point in time (Unix timestamp) when the giveaway is expected to be performed; must be from 1 minute to 7 days in the future in scheduled giveaways +//@winners_selection_date Point in time (Unix timestamp) when the giveaway is expected to be performed; must be 60-getOption("giveaway_duration_max") seconds in the future in scheduled giveaways //@only_new_subscribers True, if only new subscribers of the chats will be eligible for the giveaway //@country_codes The list of two-letter ISO 3166-1 alpha-2 codes of countries, only users from which will be eligible for the giveaway. If empty, then all users can participate in the giveaway. There can be up to getOption("giveaway_country_count_max") chosen countries premiumGiveawayParameters boosted_chat_id:int53 additional_chat_ids:vector winners_selection_date:int32 only_new_subscribers:Bool country_codes:vector = PremiumGiveawayParameters; diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 147eb471e..6cf4a0f12 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -1931,6 +1931,10 @@ void ConfigManager::process_app_config(tl_object_ptr &c get_json_value_int(std::move(key_value->value_), key)); continue; } + if (key == "giveaway_period_max") { + G()->set_option_integer("giveaway_duration_max", get_json_value_int(std::move(key_value->value_), key)); + continue; + } if (key == "channel_color_level_min") { G()->set_option_integer("channel_custom_accent_color_boost_level_min", get_json_value_int(std::move(key_value->value_), key)); diff --git a/td/telegram/ConfigManager.h b/td/telegram/ConfigManager.h index d0750da50..6dedb1a4e 100644 --- a/td/telegram/ConfigManager.h +++ b/td/telegram/ConfigManager.h @@ -102,7 +102,7 @@ class ConfigManager final : public NetQueryCallback { private: struct AppConfig { - static constexpr int32 CURRENT_VERSION = 18; + static constexpr int32 CURRENT_VERSION = 19; int32 version_ = 0; int32 hash_ = 0; telegram_api::object_ptr config_; diff --git a/td/telegram/OptionManager.cpp b/td/telegram/OptionManager.cpp index 32e851dca..43b04a3ee 100644 --- a/td/telegram/OptionManager.cpp +++ b/td/telegram/OptionManager.cpp @@ -137,6 +137,9 @@ OptionManager::OptionManager(Td *td) if (!have_option("giveaway_boost_count_per_premium")) { set_option_integer("giveaway_boost_count_per_premium", 4); } + if (!have_option("giveaway_duration_max")) { + set_option_integer("giveaway_duration_max", 7 * 86400); + } if (!have_option("channel_custom_accent_color_boost_level_min")) { set_option_integer("channel_custom_accent_color_boost_level_min", 1); }