diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index dc3e81f92..44dd2cd5e 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -22,6 +22,8 @@ DEFAULT_CONFIG = { "id_whitelist_log": True, "wl_ignore_admin_on_group": True, "wl_ignore_admin_on_friend": True, + "reply_with_mention": False, + "reply_with_quote": False, }, "provider": [], "provider_settings": { @@ -199,6 +201,16 @@ CONFIG_METADATA_2 = { "description": "管理员私聊消息无视 ID 白名单", "type": "bool", }, + "reply_with_mention": { + "description": "回复时 @ 发送者", + "type": "bool", + "hint": "启用后,机器人回复消息时会 @ 发送者。实际效果以具体的平台适配器为准。", + }, + "reply_with_quote": { + "description": "回复时引用消息", + "type": "bool", + "hint": "启用后,机器人回复消息时会引用原消息。实际效果以具体的平台适配器为准。", + }, }, }, "content_safety": { diff --git a/astrbot/core/pipeline/result_decorate/stage.py b/astrbot/core/pipeline/result_decorate/stage.py index faafe6dbd..f382fbd4b 100644 --- a/astrbot/core/pipeline/result_decorate/stage.py +++ b/astrbot/core/pipeline/result_decorate/stage.py @@ -3,8 +3,9 @@ from typing import Union, AsyncGenerator from ..stage import register_stage from ..context import PipelineContext from astrbot.core.platform.astr_message_event import AstrMessageEvent +from astrbot.core.platform.message_type import MessageType from astrbot.core import logger -from astrbot.core.message.components import Plain, Image +from astrbot.core.message.components import Plain, Image, At, Reply from astrbot.core import html_renderer from astrbot.core.star.star_handler import star_handlers_registry, EventType @@ -13,6 +14,8 @@ class ResultDecorateStage: async def initialize(self, ctx: PipelineContext): self.ctx = ctx self.reply_prefix = ctx.astrbot_config['platform_settings']['reply_prefix'] + self.reply_with_mention = ctx.astrbot_config['platform_settings']['reply_with_mention'] + self.reply_with_quote = ctx.astrbot_config['platform_settings']['reply_with_quote'] self.t2i = ctx.astrbot_config['t2i'] async def process(self, event: AstrMessageEvent) -> Union[None, AsyncGenerator[None, None]]: @@ -48,4 +51,11 @@ class ResultDecorateStage: if time.time() - render_start > 3: logger.warning("文本转图片耗时超过了 3 秒,如果觉得很慢可以使用 /t2i 关闭文本转图片模式。") if url: - result.chain = [Image.fromURL(url)] \ No newline at end of file + result.chain = [Image.fromURL(url)] + + if self.reply_with_mention and event.get_message_type() != MessageType.FRIEND_MESSAGE: + result.chain.insert(0, Plain("\n")) + result.chain.insert(0, At(qq=event.get_sender_id())) + + if self.reply_with_quote: + result.chain.insert(0, Reply(id=event.message_obj.message_id)) \ No newline at end of file