From 3f90b89c3c0220a30c16b4d53917e9fd6f8ae8b5 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Wed, 5 Feb 2025 15:06:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B1=8F=E8=94=BD=E6=97=A0?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8C=87=E4=BB=A4=E5=9B=9E=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20#361?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/config/default.py | 8 +++++++- astrbot/core/pipeline/waking_check/stage.py | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index c2e80713..0f18ba24 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -30,7 +30,8 @@ DEFAULT_CONFIG = { "only_llm_result": True, "interval": "1.5,3.5", "regex": ".*?[。?!~…]+|.+$" - } + }, + "no_permission_reply": True, }, "provider": [], "provider_settings": { @@ -194,6 +195,11 @@ CONFIG_METADATA_2 = { }, }, }, + "no_permission_reply": { + "description": "无权限回复", + "type": "bool", + "hint": "启用后,当用户没有权限执行某个操作时,机器人会回复一条消息。", + }, "segmented_reply": { "description": "分段回复", "type": "object", diff --git a/astrbot/core/pipeline/waking_check/stage.py b/astrbot/core/pipeline/waking_check/stage.py index 6d990582..6d8b9c8b 100644 --- a/astrbot/core/pipeline/waking_check/stage.py +++ b/astrbot/core/pipeline/waking_check/stage.py @@ -7,8 +7,6 @@ from astrbot.core.message.components import At from astrbot.core.star.star_handler import star_handlers_registry, EventType from astrbot.core.star.filter.command_group import CommandGroupFilter from astrbot.core.star.filter.permission import PermissionTypeFilter -from astrbot.core.star.filter.command import CommandFilter - @register_stage class WakingCheckStage(Stage): @@ -23,6 +21,9 @@ class WakingCheckStage(Stage): async def initialize(self, ctx: PipelineContext) -> None: self.ctx = ctx + self.no_permission_reply = self.ctx.astrbot_config["platform_settings"].get( + "no_permission_reply", True + ) async def process( self, event: AstrMessageEvent @@ -82,8 +83,6 @@ class WakingCheckStage(Stage): permission_not_pass = False - has_command_pass = False - if len(handler.event_filters) == 0: # 不可能有这种情况, 也不允许有这种情况 continue @@ -122,7 +121,8 @@ class WakingCheckStage(Stage): if passed: if permission_not_pass: - await event.send(MessageChain().message(f"ID {event.get_sender_id()} 权限不足")) + if self.no_permission_reply: + await event.send(MessageChain().message(f"ID {event.get_sender_id()} 权限不足")) event.stop_event() return