diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index b50bcd8dea..0156f0be97 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -37,6 +37,7 @@ "wl_ignore_admin_on_friend": True, "reply_with_mention": False, "reply_with_quote": False, + "reply_with_quote_scope": "all", # all | group_only | private_only "path_mapping": [], "segmented_reply": { "enable": False, @@ -883,6 +884,18 @@ class ChatProviderTemplate(TypedDict): "type": "bool", "hint": "启用后,机器人回复消息时会引用原消息。实际效果以具体的平台适配器为准。", }, + "reply_with_quote_scope": { + "description": "引用回复范围", + "type": "string", + "options": ["all", "group_only", "private_only"], + "labels": [ + "全部开启", + "仅群聊", + "仅私聊", + ], + "hint": "选择引用回复的生效范围。", + "condition": {"reply_with_quote": True}, + }, "path_mapping": { "type": "list", "items": {"type": "string"}, @@ -3106,6 +3119,13 @@ class ChatProviderTemplate(TypedDict): "description": "回复时引用发送人消息", "type": "bool", }, + "platform_settings.reply_with_quote_scope": { + "description": "引用回复范围", + "type": "string", + "options": ["all", "group_only", "private_only"], + "labels": ["全部开启", "仅群聊", "仅私聊"], + "condition": {"platform_settings.reply_with_quote": True}, + }, "platform_settings.forward_threshold": { "description": "转发消息的字数阈值", "type": "int", diff --git a/astrbot/core/pipeline/respond/stage.py b/astrbot/core/pipeline/respond/stage.py index 72e853ffcc..c7965e3642 100644 --- a/astrbot/core/pipeline/respond/stage.py +++ b/astrbot/core/pipeline/respond/stage.py @@ -61,6 +61,9 @@ async def initialize(self, ctx: PipelineContext) -> None: self.reply_with_quote = ctx.astrbot_config["platform_settings"][ "reply_with_quote" ] + self.reply_with_quote_scope = ctx.astrbot_config["platform_settings"].get( + "reply_with_quote_scope", "all" + ) # 分段回复 self.enable_seg: bool = ctx.astrbot_config["platform_settings"][ diff --git a/astrbot/core/pipeline/result_decorate/stage.py b/astrbot/core/pipeline/result_decorate/stage.py index 15d68fb22e..53109232b7 100644 --- a/astrbot/core/pipeline/result_decorate/stage.py +++ b/astrbot/core/pipeline/result_decorate/stage.py @@ -29,6 +29,10 @@ async def initialize(self, ctx: PipelineContext) -> None: self.reply_with_quote = ctx.astrbot_config["platform_settings"][ "reply_with_quote" ] + self.reply_with_quote_scope = ctx.astrbot_config["platform_settings"].get( + "reply_with_quote_scope", + "all", + ) self.t2i_word_threshold = ctx.astrbot_config["t2i_word_threshold"] try: self.t2i_word_threshold = int(self.t2i_word_threshold) @@ -399,5 +403,18 @@ async def process( # 引用回复 if self.reply_with_quote: - if not any(isinstance(item, File) for item in result.chain): + is_private = event.get_message_type() == MessageType.FRIEND_MESSAGE + should_quote = ( + self.reply_with_quote_scope == "all" + or ( + self.reply_with_quote_scope == "private_only" and is_private + ) + or ( + self.reply_with_quote_scope == "group_only" + and not is_private + ) + ) + if should_quote and not any( + isinstance(item, File) for item in result.chain + ): result.chain.insert(0, Reply(id=event.message_obj.message_id)) diff --git a/dashboard/src/i18n/locales/en-US/features/config-metadata.json b/dashboard/src/i18n/locales/en-US/features/config-metadata.json index 639be65781..5480c43b97 100644 --- a/dashboard/src/i18n/locales/en-US/features/config-metadata.json +++ b/dashboard/src/i18n/locales/en-US/features/config-metadata.json @@ -583,6 +583,14 @@ "reply_with_quote": { "description": "Quote Sender's Message in Reply" }, + "reply_with_quote_scope": { + "description": "Quote Reply Scope", + "labels": [ + "All", + "Group Only", + "Private Only" + ] + }, "forward_threshold": { "description": "Forward Message Word Count Threshold" }, diff --git a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json index c0838b5eea..2b29214d50 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json +++ b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json @@ -586,6 +586,13 @@ "reply_with_quote": { "description": "回复时引用发送人消息" }, + "reply_with_quote_scope": { + "description": "引用回复范围", + "labels": [ + "全部开启", + "仅群聊", + "仅私聊"] + }, "forward_threshold": { "description": "转发消息的字数阈值" },