From 7831f7d1803fdaba5c51a22232166564947e37ec Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Tue, 30 Sep 2025 22:04:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor(social=5Ftoolkit):=20=E9=80=82?= =?UTF-8?q?=E9=85=8D=E6=96=B0=E7=9A=84=E4=B8=8A=E4=B8=8B=E6=96=87=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=99=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 `chat_stream.context` 的调用更新为 `chat_stream.context_manager.context`,以适应最近对上下文管理方式的重构。 此更改确保了提醒插件与核心上下文处理逻辑保持一致,并修复了因此重构而引入的潜在错误。同时,增加了对 `last_message` 可能为空的检查,提高了代码的健壮性。 --- src/plugins/social_toolkit_plugin/plugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/social_toolkit_plugin/plugin.py b/src/plugins/social_toolkit_plugin/plugin.py index 06b2bb2d9..53eb6dd0f 100644 --- a/src/plugins/social_toolkit_plugin/plugin.py +++ b/src/plugins/social_toolkit_plugin/plugin.py @@ -63,7 +63,7 @@ class ReminderTask(AsyncTask): success, reply_set, _ = await generator_api.generate_reply( chat_stream=self.chat_stream, extra_info=extra_info, - reply_message=self.chat_stream.context.get_last_message().to_dict(), + reply_message=self.chat_stream.context_manager.context.get_last_message().to_dict(), request_type="plugin.reminder.remind_message", ) @@ -476,11 +476,12 @@ class RemindAction(BaseAction): # 4. 生成并发送确认消息 extra_info = f"你已经成功设置了一个提醒,请以一种符合你人设的、俏皮的方式回复用户。\n提醒时间: {target_time.strftime('%Y-%m-%d %H:%M:%S')}\n提醒对象: {user_name_to_remind}\n提醒内容: {event_details}" - last_message = self.chat_stream.context.get_last_message() + last_message = self.chat_stream.context_manager.context.get_last_message() + reply_message_dict = last_message.flatten() if last_message else None success, reply_set, _ = await generator_api.generate_reply( chat_stream=self.chat_stream, extra_info=extra_info, - reply_message=last_message.to_dict(), + reply_message=reply_message_dict, request_type="plugin.reminder.confirm_message", ) if success and reply_set: