From 9d075736c9fc1148cd5b777451e8e8e53c7e30e0 Mon Sep 17 00:00:00 2001 From: Aldrich Chen <109075336+Chen17-sq@users.noreply.github.com> Date: Mon, 27 Apr 2026 22:15:38 +0800 Subject: [PATCH] feat(export): add --media flag for parity with history command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The --media flag was added to the history command in v0.2.4 (f6410d3) to resolve image/file/video/voice paths inline. The export command does the same thing — bulk-format messages for an external consumer — but never got the matching flag, so exporting to Markdown for Graphify or other downstream tools loses media path information. This adds the --media flag to export, passing resolve_media=media and db_dir=app.db_dir through to collect_chat_history. No changes to core/messages.py — the path-resolution logic is already in place from f6410d3. 5 lines changed in wechat_cli/commands/export.py. --- wechat_cli/commands/export.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wechat_cli/commands/export.py b/wechat_cli/commands/export.py index c1be606..42382da 100644 --- a/wechat_cli/commands/export.py +++ b/wechat_cli/commands/export.py @@ -20,8 +20,9 @@ @click.option("--start-time", default="", help="起始时间 YYYY-MM-DD [HH:MM[:SS]]") @click.option("--end-time", default="", help="结束时间 YYYY-MM-DD [HH:MM[:SS]]") @click.option("--limit", default=500, help="导出消息数量") +@click.option("--media", is_flag=True, help="解析媒体文件路径(图片/文件/视频/语音)") @click.pass_context -def export(ctx, chat_name, fmt, output_path, start_time, end_time, limit): +def export(ctx, chat_name, fmt, output_path, start_time, end_time, limit, media): """导出聊天记录为 markdown 或纯文本 \b @@ -29,6 +30,7 @@ def export(ctx, chat_name, fmt, output_path, start_time, end_time, limit): wechat-cli export "张三" --format markdown wechat-cli export "AI交流群" --format txt --output chat.txt wechat-cli export "张三" --start-time "2026-04-01" --limit 1000 + wechat-cli export "张三" --media --output chat.md # 解析图片/文件本地路径 """ app = ctx.obj @@ -51,6 +53,7 @@ def export(ctx, chat_name, fmt, output_path, start_time, end_time, limit): lines, failures = collect_chat_history( chat_ctx, names, app.display_name_fn, start_ts=start_ts, end_ts=end_ts, limit=limit, offset=0, + resolve_media=media, db_dir=app.db_dir, ) if not lines: