diff --git a/EXE_USAGE.md b/EXE_USAGE.md index a0ffbbf..af69994 100644 --- a/EXE_USAGE.md +++ b/EXE_USAGE.md @@ -16,9 +16,14 @@ .\WeChatDecrypt.exe status .\WeChatDecrypt.exe decrypt .\WeChatDecrypt.exe export --from-plan-csv export_plan.csv +.\WeChatDecrypt.exe export-all output_dir --delta-only --start "2026-05-26 00:00:00" --end "2026-05-26 08:00:00" .\WeChatDecrypt.exe export-all --write-plan-csv export_plan.csv ``` +`--delta-only` 只写入时间窗口内的 delta JSON,不读取或覆盖已有完整 JSON。 +输出里每条消息包含 `msg_uid`,下游可以用它做去重;时间窗口内没有消息的会话会跳过, +不生成空的 `*.delta.json` 文件。 + 无参数或 `web` 子命令仍启动 Web UI: ```powershell @@ -99,6 +104,7 @@ wechat_files// ← 导出的聊天记录 (按 wxid + 联系人分 朋友圈图片/ ← 朋友圈缓存图片解密后 data/ ← 语音转 MP3 输出 (有的话) exported_chats/ ← 用 ③ 导出全部聊天 (JSON) 时的输出 (export_all_chats.py) + deltas// ← --delta-only 输出 manifest.json + 非空 chats/*.delta.json wxwork_export/ ← 企微聊天导出 ``` diff --git a/README.md b/README.md index fb2f2e7..b1619c2 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ py -m pip install --user -r requirements.txt | 生成导出计划 CSV(白名单) | `python export_all_chats.py --write-plan-csv export_plan.csv --plan-mode whitelist` | | 按计划 CSV 导出(黑名单,默认) | `python export_all_chats.py output_dir --from-plan-csv export_plan.csv` | | 按计划 CSV 导出(白名单) | `python export_all_chats.py output_dir --from-plan-csv export_plan.csv --plan-mode whitelist` | +| 导出时间窗口 delta JSON(不覆盖完整 JSON) | `python export_all_chats.py output_dir --delta-only --start "2026-05-26 00:00:00" --end "2026-05-26 08:00:00"` | | 批量导出 + 语音转录 | `python export_all_chats.py --with-transcriptions` | | 转录单个文件语音 | `python transcribe_chat.py input.json [output.json]` | | 注册 MCP Server(Claude) | `claude mcp add wechat -- python /path/to/mcp_server.py` | @@ -235,6 +236,10 @@ py -m pip install --user -r requirements.txt 的行会被跳过,空值、`1` 或没有 `export` 列都会导出;`whitelist` 模式下只有明确 `export=1` 的行会导出。 +`--delta-only` 是无状态时间窗口导出,必须显式传 `--start`。它不会读取或 +覆盖 `exported_chats/*.json`,适合由外部调度器维护游标后定时拉取新增消息。 +时间窗口内没有消息的会话会跳过,不生成空的 `*.delta.json` 文件。 + ### Web UI `python main.py` 启动后打开 http://localhost:5678 查看实时消息流。 @@ -398,7 +403,7 @@ make help # 列出所有命令 | 文件 | 说明 | |---|---| -| `export_all_chats.py` | 批量导出全部聊天为 JSON (含 CSV 计划选择、`-t` 转录、`-i` 增量、日期范围、`--dry-run`) | +| `export_all_chats.py` | 批量导出全部聊天为 JSON (含 CSV 计划选择、`--delta-only` 时间窗口、`-t` 转录、`-i` 增量、日期范围、`--dry-run`) | | `export_chat.py` | 单会话 JSON 导出 (供 `export_all_chats` 调用) | | `chat_export_helpers.py` | JSON 导出共享格式化函数 (避免漂移) | | `export_messages.py` | CSV / HTML / JSON 三种格式导出, 图片可内联 (PR #107) | diff --git a/docs/chat_export_format.md b/docs/chat_export_format.md index f4b5403..a6c4f5a 100644 --- a/docs/chat_export_format.md +++ b/docs/chat_export_format.md @@ -110,3 +110,24 @@ pending = [m for m in data["messages"] `[图片]` 等。原始媒体仍在 WeChat DB 中,可用 `mcp_server.py` 中的 辅助函数(`decode_image`、`decode_voice`)取出。 - **群聊**中的 `sender` 是群成员解析后的显示名;当前登录用户仍为 `"me"`。 + +## Delta JSON 输出 + +`export_all_chats.py --delta-only --start