wechat-draft-publisher

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

微信公众号草稿发布器(小龙虾极速版)

WeChat Official Account Draft Publisher (Crayfish Express Version)

核心理念:首次引导配置,之后一键发布

Core Concept: Guide configuration on first use, one-click publishing afterwards



前置:安装依赖

Prerequisite: Install Dependencies

每次使用前,先确保依赖已安装(幂等操作,可重复执行):
bash
pip3 install -r skills/wechat-draft-publisher/requirements.txt

Before each use, ensure dependencies are installed (idempotent operation, can be executed repeatedly):
bash
pip3 install -r skills/wechat-draft-publisher/requirements.txt

首次使用:引导配置

First-time Use: Guided Configuration

第1步:查询IP并告知用户

Step 1: Query IP and Notify User

每次首次使用或遇到IP白名单错误时,先帮用户查询IP:
bash
python publisher.py --query-ip
这会自动查询公网IP并显示:
>>> 你的公网IP是: x.x.x.x

请将此IP添加到微信公众号后台:
1. 登录 https://developers.weixin.qq.com/platform
2. 设置与开发 → 基本配置 → IP白名单
3. 添加IP: x.x.x.x
告诉用户:
首次使用需要配置两件事:

1. IP白名单:我已查到你的服务器IP是 x.x.x.x
   请登录微信公众号后台,在 设置与开发→基本配置→IP白名单 中添加这个IP

2. AppID和AppSecret:
   在同一页面(基本配置)中复制AppID和AppSecret
   运行发布工具时会自动引导你填写

配置好了告诉我,我就帮你发布!
Query IP for users when using for the first time or encountering IP whitelist errors:
bash
python publisher.py --query-ip
This will automatically query the public IP and display:
>>> Your public IP is: x.x.x.x

Please add this IP to the WeChat Official Account backend:
1. Log in to https://developers.weixin.qq.com/platform
2. Settings & Development → Basic Configuration → IP Whitelist
3. Add IP: x.x.x.x
Tell the user:
Two configurations are required for first-time use:

1. IP Whitelist: I have found your server IP is x.x.x.x
   Please log in to the WeChat Official Account backend, and add this IP in Settings & Development→Basic Configuration→IP Whitelist

2. AppID and AppSecret:
   Copy AppID and AppSecret from the same page (Basic Configuration)
   The publishing tool will automatically guide you to fill them in when running

Let me know once configured, and I will help you publish!

第2步:运行发布器(自动引导输入凭证)

Step 2: Run the Publisher (Automatically Guide Credential Input)

bash
python publisher.py --title "文章标题" --content article.html
首次运行会自动提示输入 AppID 和 AppSecret。

bash
python publisher.py --title "Article Title" --content article.html
The first run will automatically prompt you to enter AppID and AppSecret.

正常发布流程(配置完成后)

Normal Publishing Process (After Configuration)

一键发布

One-click Publishing

bash
python publisher.py \
  --title "文章标题" \
  --content xxx_formatted.html \
  --cover cover.png \
  --author "小龙虾"
bash
python publisher.py \
  --title "Article Title" \
  --content xxx_formatted.html \
  --cover cover.png \
  --author "Crayfish"

自动执行步骤

Automatic Execution Steps

  1. 找 HTML 文件:优先
    *_formatted.html
    ,回退最新
    .html
  2. 提取标题:从 HTML 注释或文件名
  3. 找封面图
    cover.png
  4. 调用发布:上传封面 → 上传内容图片 → 创建草稿
  5. 返回结果:显示 media_id,提示去后台查看
  1. Find HTML File: Prioritize
    *_formatted.html
    , fall back to the latest
    .html
  2. Extract Title: From HTML comments or file name
  3. Find Cover Image:
    cover.png
  4. Call Publishing: Upload cover → Upload content images → Create draft
  5. Return Result: Display media_id, prompt to check in backend

发布成功后提示

Prompt After Successful Publishing

✅ 文章已推送到草稿箱!

接下来:
1. 登录 https://developers.weixin.qq.com/platform
2. 进入"草稿箱"
3. 预览效果,确认后发布

⚠️ 草稿不会自动发布,你可以在后台编辑后再发

✅ Article has been pushed to the draft box!

Next steps:
1. Log in to https://developers.weixin.qq.com/platform
2. Enter "Draft Box"
3. Preview the effect, then publish after confirmation

⚠️ Drafts will not be published automatically, you can edit them in the backend before publishing

常见错误速查

Quick Troubleshooting

错误原因解决
invalid ip not in whitelist
IP不在白名单运行
python publisher.py --query-ip
查IP并添加
AppSecret error
凭证错误检查
~/.wechat-publisher/config.json
title size out of limit
标题太长工具会自动截断,无需处理
api功能未授权
公众号类型不支持需要认证的服务号

ErrorCauseSolution
invalid ip not in whitelist
IP is not in whitelistRun
python publisher.py --query-ip
to check IP and add it
AppSecret error
Invalid credentialCheck
~/.wechat-publisher/config.json
title size out of limit
Title is too longThe tool will automatically truncate it, no manual handling needed
api function not authorized
Official Account type does not supportAuthenticated service account is required

配置文件位置

Configuration File Location

~/.wechat-publisher/config.json
json
{
  "appid": "xxx",
  "appsecret": "xxx"
}

~/.wechat-publisher/config.json
json
{
  "appid": "xxx",
  "appsecret": "xxx"
}

完整工作流联动

Complete Workflow Integration

写文章(tech-writer/pm-writer) → 美化格式(formatter) → 推送到微信(本skill)
用户只需要说三句话:
  1. "写一篇关于XXX的文章"
  2. "美化文章"
  3. "推送到微信"
Write article(tech-writer/pm-writer) → Format beautification(formatter) → Push to WeChat(this skill)
Users only need to say three sentences:
  1. "Write an article about XXX"
  2. "Beautify the article"
  3. "Push to WeChat"