From df8944ec73942383b863069ccb28ebe57ddc0f2b Mon Sep 17 00:00:00 2001 From: FuQuan233 Date: Tue, 18 Feb 2025 18:17:53 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20send=20reasoning=20content=20via=20?= =?UTF-8?q?forward=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_llmchat/__init__.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/nonebot_plugin_llmchat/__init__.py b/nonebot_plugin_llmchat/__init__.py index 417b7f6..6d73c02 100644 --- a/nonebot_plugin_llmchat/__init__.py +++ b/nonebot_plugin_llmchat/__init__.py @@ -16,6 +16,7 @@ from nonebot import ( on_command, on_message, require, + get_bot, ) from nonebot.adapters.onebot.v11 import GroupMessageEvent, Message from nonebot.adapters.onebot.v11.permission import GROUP_ADMIN, GROUP_OWNER @@ -125,6 +126,29 @@ def format_message(event: GroupMessageEvent) -> str: return json.dumps(message, ensure_ascii=False) +def build_reasoning_forward_nodes(self_id: str, reasoning_content: str): + self_nickname = next(iter(driver.config.nickname)) + nodes = [ + { + "type": "node", + "data": { + "name": self_nickname, + "uin": self_id, + "content": f"{self_nickname}的内心OS:", + }, + }, + { + "type": "node", + "data": { + "name": self_nickname, + "uin": self_id, + "content": reasoning_content, + }, + }, + ] + + return nodes + async def is_triggered(event: GroupMessageEvent) -> bool: """扩展后的消息处理规则""" @@ -245,7 +269,10 @@ async def process_messages(group_id: int): ) if state.output_reasoning_content and reasoning_content: - await handler.send(Message(reasoning_content)) + bot = get_bot(str(event.self_id)) + await bot.send_group_forward_msg( + group_id=group_id, messages=build_reasoning_forward_nodes(bot.self_id,reasoning_content) + ) assert reply is not None logger.info(