从内容策划到微信服务号草稿箱的全流程自动化 | v3.1.0
微信服务号运营全流程覆盖:选题策划、文章生成、配图设计、草稿发布、菜单栏管理、Skill 市场维护、文章索引更新、PR 代码审查。
wechat-article-publish/
├── scripts/
│ ├── publish.py # 发布脚本(草稿创建/替换/回滚)
│ ├── config.py # 配置管理(环境变量读取凭证)
│ └── post_publish.py # 发布后同步脚本
├── .gitignore # 敏感文件排除
├── requirements.txt # 依赖管理
├── VERSION # 版本号
├── SKILL.md # 工作流文档
└── README.md
脚本通过环境变量读取敏感凭证,不再硬编码:
# 必须设置
export WECHAT_APP_ID="你的AppID"
export WECHAT_APP_SECRET="你的AppSecret"
# CNB API 调用需要
export CNB_TOKEN="你的CNB令牌"
注意: 请勿将凭证写入代码或提交到版本控制。
.gitignore已排除.env、TOOLS.md、config.json等敏感文件。
# 设置环境变量
export WECHAT_APP_ID="wx..."
export WECHAT_APP_SECRET="..."
# 预检模式(不实际发布)
python scripts/publish.py --dry-run \
--title "文章标题" \
--digest "摘要" \
--content-html content.html \
--cover-image cover.png \
--card-images card1.png card2.png
# 正式发布
python scripts/publish.py \
--title "文章标题" \
--digest "摘要" \
--content-html content.html \
--cover-image cover.png \
--card-images card1.png card2.png
python scripts/publish.py \
--title "新标题" \
--digest "新摘要" \
--content-html content.html \
--cover-image cover.png \
--old-draft-media-id 旧草稿ID
export CNB_TOKEN="..."
python scripts/post_publish.py \
--title "文章标题" \
--article-url "https://mp.weixin.qq.com/s?..." \
--publish-date 2026-05-15
# 查看草稿备份信息
python scripts/publish.py --rollback --media-id 草稿ID
# 微信公众号凭证(必须)
export WECHAT_APP_ID="wx..."
export WECHAT_APP_SECRET="..."
⚠️ 安全提醒:AppID/AppSecret 绝不写入代码或提交到仓库。
TOOLS.md、config.json、.env等敏感文件已加入.gitignore。
# 基本用法
python scripts/publish.py \
--title "文章标题(≤64字)" \
--digest "文章摘要(≤120字)" \
--content-html content.html \
--cover-image cover.png \
--card-images card1.png card2.png
# dry-run 模式(仅校验,不调用 API)
python scripts/publish.py --dry-run \
--title "标题" --content-html content.html --cover-image cover.png
# 查询
python scripts/publish.py --list-drafts
python scripts/publish.py --list-published
python scripts/post_publish.py --article-title "标题" --article-url "https://..." update-meta
wechat-article-publish/
├── scripts/
│ ├── publish.py # 草稿发布脚本
│ ├── config.py # 配置管理(环境变量)
│ └── post_publish.py # 发布后同步脚本
├── requirements.txt
├── VERSION
├── .gitignore
├── SKILL.md # 完整工作流文档
└── README.md
发文章、服务号图文、微信公众号发布、推文、群发、选题、菜单栏、Skill 市场、文章索引
| 依赖 | 说明 |
|---|---|
| curl | API 调用 |
| python3 | 脚本执行 |
| rsvg-convert | SVG 转 PNG |
一篇一 Skill — 每篇文章对应独立 Skill 实例。
当前版本: v3.1.0(见 VERSION)