Commit 56a141d

benny-dou <60535774+benny-dou@users.noreply.github.com>
2026-06-09 03:09:16
chore(history): minor update
1 parent 86a2cbe
Changed files (1)
src/ai/chat_summary.py
@@ -172,7 +172,7 @@ async def ai_chat_summary(
         res = await send2tg(client, message, texts=f"📝正在获取历史消息...\n⏩开始时间: {begin_time:%m-%d %H:%M:%S}\n⏯️结束时间: {end_time:%m-%d %H:%M:%S}", **kwargs)
         kwargs["progress"] = res[0]
     history_list = await get_history_info_list(client, info["cid"], offset_id, num_history, begin_time, end_time, filter_users)
-    parsed = await parse_history_list(history_list)  # parse the history as csv
+    parsed = parse_history_list(history_list)  # parse the history as csv
     if parsed.get("num_message", 0) == 0:
         await send2tg(client, message, texts=f"{num_history}条历史消息中未找到符合条件的消息", **kwargs)
         await modify_progress(del_status=True, **kwargs)
@@ -202,7 +202,7 @@ async def ai_chat_summary(
         await modify_progress(del_status=True, **kwargs)
 
 
-async def parse_history_list(info_list: list[dict]) -> dict:
+def parse_history_list(info_list: list[dict]) -> dict:
     """Parse chat history info list.
 
     Currently, we only summarize text contents.
@@ -241,7 +241,10 @@ async def parse_history_list(info_list: list[dict]) -> dict:
         reply_msg_content = reply_msg.get("message", "")
         if len(reply_msg_content) > 30:
             reply_msg_content = reply_msg_content[:30] + "..."
-        history_csv += f"{message_id - msg_offset}\t{username}\t{content}\t{reply_to_message_id - msg_offset}\t{reply_msg_content}\n"
+        if reply_msg:
+            history_csv += f"{message_id - msg_offset}\t{username}\t{content}\t{reply_to_message_id - msg_offset}\t{reply_msg_content}\n"
+        else:
+            history_csv += f"{message_id - msg_offset}\t{username}\t{content}\t \t \n"
     if not history_csv:
         return {}
 
@@ -267,7 +270,7 @@ def get_txt_format(info_list: list[dict]) -> str:
         if info["media_group_id"] in txt_mediagroup_ids:
             continue
         # add txt format
-        txt_format += f"[{info['datetime']:%m-%d %H:%M:%S}]{info['full_name']}:\n"
+        txt_format += f"[{info['datetime']:%Y-%m-%d %H:%M:%S}]{info['full_name']}:\n"
         if info["mtype"] != "text":  # not plaintext message
             # media group
             if info["media_group_id"]: