自动将 HTML 文章发布到微信公众号草稿箱,支持封面图上传、标题、作者和元数据管理。当用户说"推送到微信"、"发布到公众号草稿"、"上传到草稿箱"或提到微信文章发布时使用。
自动将 HTML 格式的文章发布到微信公众号草稿箱,支持封面图上传、标题、作者和摘要等元数据管理。
最简单的用法:
python publisher.py --title "文章标题" --content article.html
完整参数:
python publisher.py \
--title "标题" \
--content article.html \
--author "作者名" \
--cover cover.png \
--digest "文章摘要"
默认值:
YanGcover.png发布文章到微信草稿箱的完整流程:
查找 HTML 文件
*_formatted.html.html 文件提取文章标题
<!-- Title: xxx -->检查封面图
cover.png调用发布脚本
python publisher.py --title "xxx" --content xxx.html --cover xxx.png
验证结果
提示用户
工具会在首次运行时引导配置:
获取微信公众号凭证
运行发布器
python publisher.py --title "测试" --content test.html
添加服务器 IP 到白名单(如需要)
位置: ~/.wechat-publisher/config.json
格式:
{
"appid": "wx1234567890abcdef",
"appsecret": "your_secret_here"
}
与其他 skill 协同工作:
完整工作流:
wechat-tech-writer → 生成文章(xxx_article.md + cover.png)wechat-article-formatter → 格式化 HTML(xxx_formatted.html)wechat-draft-publisher → 发布到微信草稿箱(本 skill)自动检测机制:
*_formatted.html 文件cover.png 封面图症状: invalid ip not in whitelist
解决:
症状: AppSecret error
解决:
~/.wechat-publisher/config.json症状: title/author size out of limit
解决:
publisher.pywechat-draft-publisher/
├── SKILL.md # 本文件
├── publisher.py # 核心发布脚本
├── scripts/ # 工具脚本
│ ├── fix-wechat-style.py # HTML 优化器
│ ├── optimize-html.py # HTML 压缩工具
│ ├── publish-workflow.sh # 完整工作流
│ ├── install.sh # 安装助手
│ └── test.sh # 测试脚本
├── examples/ # 示例文件
│ ├── config.json.example # 配置示例
│ └── example.html # HTML 示例
└── README.md # 详细英文文档
示例 1:标准发布
python publisher.py \
--title "VSCode 更名事件" \
--content article.html
示例 2:完整元数据
python publisher.py \
--title "技术文章" \
--content article.html \
--author "YanG" \
--cover images/cover.png \
--digest "这是一篇关于..."
示例 3:交互模式
python publisher.py --interactive
发布成功后:
注意事项: