|
|
@@ -256,18 +256,18 @@ async def feishu_send_message_to_contact(
|
|
|
update_contact_chat_id(contact_name, last_res.chat_id)
|
|
|
|
|
|
# [待开启] 发送即记录:为了维护完整的聊天记录,将机器人发出的消息也保存到本地文件
|
|
|
- # try:
|
|
|
- # history = load_chat_history(contact_name)
|
|
|
- # history.append({
|
|
|
- # "role": "assistant",
|
|
|
- # "message_id": last_res.message_id,
|
|
|
- # "content": content if isinstance(content, list) else [{"type": "text", "text": content}]
|
|
|
- # })
|
|
|
- # save_chat_history(contact_name, history)
|
|
|
- # # 机器人回复了,将该联系人的未读计数重置为 0
|
|
|
- # update_unread_count(contact_name, reset=True)
|
|
|
- # except Exception as e:
|
|
|
- # print(f"记录发送的消息失败: {e}")
|
|
|
+ try:
|
|
|
+ history = load_chat_history(contact_name)
|
|
|
+ history.append({
|
|
|
+ "role": "assistant",
|
|
|
+ "message_id": last_res.message_id,
|
|
|
+ "content": content if isinstance(content, list) else [{"type": "text", "text": content}]
|
|
|
+ })
|
|
|
+ save_chat_history(contact_name, history)
|
|
|
+ # 机器人回复了,将该联系人的未读计数重置为 0
|
|
|
+ update_unread_count(contact_name, reset=True)
|
|
|
+ except Exception as e:
|
|
|
+ print(f"记录发送的消息失败: {e}")
|
|
|
|
|
|
return ToolResult(
|
|
|
title=f"消息已成功发送至 {contact_name}",
|