From 771c045844dcba0dddbdcbf8ddf04efa91036475 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sun, 22 Dec 2024 05:18:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=AF=E9=85=8D=E7=BD=AE=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=90=AF=E7=94=A8=E7=99=BD=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/config/default.py | 5 +++++ astrbot/core/pipeline/whitelist_check/stage.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index f7a0201b4..5e86c0f59 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -17,6 +17,7 @@ DEFAULT_CONFIG = { }, "reply_prefix": "", "forward_threshold": 200, + "enable_id_white_list": True, "id_whitelist": [], "id_whitelist_log": True, "wl_ignore_admin_on_group": True, @@ -162,6 +163,10 @@ CONFIG_METADATA_2 = { "type": "int", "hint": "超过一定字数后,机器人会将消息折叠成 QQ 群聊的 “转发消息”,以防止刷屏。目前仅 QQ 平台适配器适用。", }, + "enable_id_white_list": { + "description": "启用 ID 白名单", + "type": "bool" + }, "id_whitelist": { "description": "ID 白名单", "type": "list", diff --git a/astrbot/core/pipeline/whitelist_check/stage.py b/astrbot/core/pipeline/whitelist_check/stage.py index b2b713a6a..6a4e7097e 100644 --- a/astrbot/core/pipeline/whitelist_check/stage.py +++ b/astrbot/core/pipeline/whitelist_check/stage.py @@ -10,12 +10,16 @@ class WhitelistCheckStage(Stage): '''检查是否在群聊/私聊白名单 ''' async def initialize(self, ctx: PipelineContext) -> None: + self.enable_whitelist_check = ctx.astrbot_config['platform_settings']['enable_id_white_list'] self.whitelist = ctx.astrbot_config['platform_settings']['id_whitelist'] self.wl_ignore_admin_on_group = ctx.astrbot_config['platform_settings']['wl_ignore_admin_on_group'] self.wl_ignore_admin_on_friend = ctx.astrbot_config['platform_settings']['wl_ignore_admin_on_friend'] self.wl_log = ctx.astrbot_config['platform_settings']['id_whitelist_log'] async def process(self, event: AstrMessageEvent) -> Union[None, AsyncGenerator[None, None]]: + if not self.enable_whitelist_check: + return + # 检查是否在白名单 if self.wl_ignore_admin_on_group: if event.role == 'admin' and event.get_message_type() == MessageType.GROUP_MESSAGE: