refactor(social_toolkit): 适配新的上下文管理器接口
将 `chat_stream.context` 的调用更新为 `chat_stream.context_manager.context`,以适应最近对上下文管理方式的重构。 此更改确保了提醒插件与核心上下文处理逻辑保持一致,并修复了因此重构而引入的潜在错误。同时,增加了对 `last_message` 可能为空的检查,提高了代码的健壮性。
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user