Skip to content

Commit aba4ef5

Browse files
committed
feat: respect global anti_anonymous settings
1 parent 02cceaa commit aba4ef5

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

config.example.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ features:
5050
# 启用反频道马甲
5151
anti_anonymous:
5252
enable: false
53-
also_ban: false
54-
whitelist:
55-
- 123456789 # 默认允许的频道身份 ID 列表
53+
# 其它选项需要在群组内配置
5654

5755
# group features settings
5856
# 群组 id,使用 bot api(bot 内置的 info 命令)

config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def _normalize_enabled_dicts(cfg: Any) -> Any:
120120
# Fallback to global features if neither DB nor file has group config
121121
return self.config_data.get('features', {})
122122
else:
123-
124123
db_config = _fill_none(db_config, file_cfg)
125124
if file_cfg:
126125
global_features = self.config_data.get('features', {})

core/anti_fake_users.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
from aiogram.types import Message
44

5+
from config import config
6+
57
async def handle_whitelist_command(message: Message):
68
"""处理白名单命令"""
79
chat_id = message.chat.id
10+
if config.is_feature_enabled('anti_anonymous', chat_id) is False:
11+
return
812
try:
913
channel_id = int(message.text.split(' ')[1])
1014
except (IndexError, ValueError):
@@ -23,6 +27,8 @@ async def handle_whitelist_command(message: Message):
2327
async def handle_remove_whitelist_command(message: Message):
2428
"""处理移除白名单命令"""
2529
chat_id = message.chat.id
30+
if config.is_feature_enabled('anti_anonymous', chat_id) is False:
31+
return
2632
try:
2733
channel_id = int(message.text.split(' ')[1])
2834
except (IndexError, ValueError):
@@ -45,6 +51,8 @@ async def handle_enable_also_ban_command(message: Message):
4551
await message.reply("用法: /also_auto_ban_channel [on|off]")
4652
return
4753
chat_id = message.chat.id
54+
if config.is_feature_enabled('anti_anonymous', chat_id) is False:
55+
return
4856
member = await message.chat.get_member(message.from_user.id)
4957
is_group_anonymous_admin = message.sender_chat and message.sender_chat.id == message.chat.id
5058
if not member.status in ['administrator', 'creator'] and not is_group_anonymous_admin:
@@ -61,6 +69,8 @@ async def handle_enable_also_ban_command(message: Message):
6169
async def handle_anonymous_channel_msgs(message: Message):
6270
"""处理来自匿名频道的消息"""
6371
chat_id = message.chat.id
72+
if config.is_feature_enabled('anti_anonymous', chat_id) is False:
73+
return
6474
channel_id = message.sender_chat.id if message.sender_chat else None
6575
is_from_binded_channel = message.is_automatic_forward
6676
is_group_anonymous_admin = message.sender_chat and message.sender_chat.id == message.chat.id

0 commit comments

Comments
 (0)