Add "aggressive_anti_spam_supergroup_member_count_min" option.

This commit is contained in:
levlam 2022-11-25 17:16:37 +03:00
parent e6941d231d
commit f7897dc2ba
3 changed files with 13 additions and 4 deletions

View File

@ -6428,7 +6428,7 @@ toggleSupergroupJoinByRequest supergroup_id:int53 join_by_request:Bool = Ok;
//@description Toggles whether the message history of a supergroup is available to new members; requires can_change_info administrator right @supergroup_id The identifier of the supergroup @is_all_history_available The new value of is_all_history_available
toggleSupergroupIsAllHistoryAvailable supergroup_id:int53 is_all_history_available:Bool = Ok;
//@description Toggles whether aggressive anti-spam checks are enabled in the supergroup; requires can_delete_messages administrator right @supergroup_id The identifier of the supergroup, which isn't a broadcast group @is_aggressive_anti_spam_enabled The new value of is_aggressive_anti_spam_enabled
//@description Toggles whether aggressive anti-spam checks are enabled in the supergroup; requires can_delete_messages administrator right. Can be called only if the supergroup has at least GetOption("aggressive_anti_spam_supergroup_member_count_min") members @supergroup_id The identifier of the supergroup, which isn't a broadcast group @is_aggressive_anti_spam_enabled The new value of is_aggressive_anti_spam_enabled
toggleSupergroupIsAggressiveAntiSpamEnabled supergroup_id:int53 is_aggressive_anti_spam_enabled:Bool = Ok;
//@description Toggles whether the supergroup is a forum; requires owner privileges in the supergroup @supergroup_id Identifier of the supergroup @is_forum New value of is_forum. A supergroup can be converted to a forum, only if it has at least GetOption("forum_member_count_min") members

View File

@ -1492,6 +1492,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
int32 stickers_premium_by_emoji_num = 0;
int32 stickers_normal_by_emoji_per_premium_num = 2;
int32 forum_upgrade_participants_min = 200;
int32 telegram_antispam_group_size_min = 100;
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_;
@ -1853,6 +1854,10 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
G()->set_option_integer("telegram_antispam_user_id", setting_value);
continue;
}
if (key == "telegram_antispam_group_size_min") {
telegram_antispam_group_size_min = get_json_value_int(std::move(key_value->value_), key);
continue;
}
new_values.push_back(std::move(key_value));
}
@ -1939,11 +1944,12 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
} else {
options.set_option_integer("reactions_uniq_max", reactions_uniq_max);
}
if (forum_upgrade_participants_min < 0) {
options.set_option_empty("forum_member_count_min");
} else {
if (forum_upgrade_participants_min >= 0) {
options.set_option_integer("forum_member_count_min", forum_upgrade_participants_min);
}
if (telegram_antispam_group_size_min >= 0) {
options.set_option_integer("aggressive_anti_spam_supergroup_member_count_min", telegram_antispam_group_size_min);
}
bool is_premium = options.get_option_boolean("is_premium");

View File

@ -119,6 +119,9 @@ OptionManager::OptionManager(Td *td)
if (!have_option("forum_member_count_min")) {
set_option_integer("forum_member_count_min", 200);
}
if (!have_option("aggressive_anti_spam_supergroup_member_count_min")) {
set_option_integer("aggressive_anti_spam_supergroup_member_count_min", G()->is_test_dc() ? 1 : 100);
}
}
OptionManager::~OptionManager() = default;