Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion wechat_cli/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
@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
示例:
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

Expand All @@ -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:
Expand Down