Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions astrbot/core/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions astrbot/core/pipeline/respond/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"][
Expand Down
19 changes: 18 additions & 1 deletion astrbot/core/pipeline/result_decorate/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,13 @@
"reply_with_quote": {
"description": "回复时引用发送人消息"
},
"reply_with_quote_scope": {
"description": "引用回复范围",
"labels": [
"全部开启",
"仅群聊",
"仅私聊"]
},
"forward_threshold": {
"description": "转发消息的字数阈值"
},
Expand Down