From 3eb49f7422a970773351992f657d9b82f14d1810 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sun, 9 Mar 2025 18:03:23 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E7=A7=81=E8=81=8A=E6=98=AF=E5=90=A6=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=94=A4=E9=86=92=E5=89=8D=E7=BC=80=E5=94=A4=E9=86=92=20#735?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/config/default.py | 6 ++++++ astrbot/core/pipeline/waking_check/stage.py | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 78c56470d..a8fab4ea9 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -37,6 +37,7 @@ DEFAULT_CONFIG = { }, "no_permission_reply": True, "empty_mention_waiting": True, + "friend_message_needs_wake_prefix": False, }, "provider": [], "provider_settings": { @@ -270,6 +271,11 @@ CONFIG_METADATA_2 = { "type": "bool", "hint": "启用后,当消息内容只有 @ 机器人时,会触发等待回复,在 60 秒内的该用户的任意一条消息均会唤醒机器人。这在某些平台不支持 @ 和语音/图片等消息同时发送时特别有用。", }, + "friend_message_needs_wake_prefix": { + "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 d18a0b5c8..95f70fd4d 100644 --- a/astrbot/core/pipeline/waking_check/stage.py +++ b/astrbot/core/pipeline/waking_check/stage.py @@ -25,6 +25,10 @@ class WakingCheckStage(Stage): self.no_permission_reply = self.ctx.astrbot_config["platform_settings"].get( "no_permission_reply", True ) + # 私聊是否需要 wake_prefix 才能唤醒机器人 + self.friend_message_needs_wake_prefix = self.ctx.astrbot_config[ + "platform_settings" + ].get("friend_message_needs_wake_prefix", False) async def process( self, event: AstrMessageEvent @@ -68,7 +72,7 @@ class WakingCheckStage(Stage): event.is_at_or_wake_command = True break # 检查是否是私聊 - if event.is_private_chat(): + if event.is_private_chat() and not self.friend_message_needs_wake_prefix: is_wake = True event.is_wake = True event.is_at_or_wake_command = True