SuperAPI AI Directory

wechat-draft-publisher

Office & productivity

View repository

Updated 10-15 20:07

About this skill

WeChat Official Account Draft Publisher (Crayfish Speed Version)

Core concept: guide configuration on first use, then one-click publishing afterward


Prerequisite: Install dependencies

Before each use, first make sure the dependencies are installed (idempotent operation, can be run repeatedly):

pip3 install -r skills/wechat-draft-publisher/requirements.txt

First use: Guided configuration

Step 1: Query the IP and inform the user

On each first use or when encountering an IP whitelist error, first help the user query the IP:

python publisher.py --query-ip

This will automatically query the public IP and display:

>>> 你的公网IP是: x.x.x.x

请将此IP添加到微信公众号后台:
1. 登录 https://developers.weixin.qq.com/platform
2. 设置与开发 → 基本配置 → IP白名单
3. 添加IP: x.x.x.x

Tell the user:

首次使用需要配置两件事:

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

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

配置好了告诉我,我就帮你发布!

Step 2: Run the publisher (automatically guides credential input)

python publisher.py --title "文章标题" --content article.html

On first run, it will automatically prompt for the AppID and AppSecret.


Normal publishing process (after configuration is complete)

One-click publishing

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

Automatically executed steps

  1. Find the HTML file: prefer *_formatted.html, fall back to the latest .html
  2. Extract the title: from HTML comments or the file name
  3. Find the cover image:cover.png
  4. Call publishing: upload cover → upload content images → create draft
  5. Return the result: display the media_id, prompt to check in the backend

Prompt after successful publishing

✅ 文章已推送到草稿箱!

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

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

Common error quick reference

Error Cause Solution
invalid ip not in whitelist IP not in whitelist Run python publisher.py --query-ip to check the IP and add it
AppSecret error Incorrect credentials Check ~/.wechat-publisher/config.json
title size out of limit Title too long The tool will automatically truncate it, no action needed
api功能未授权 Official Account type not supported Requires a verified service account

Configuration file location

~/.wechat-publisher/config.json

{
  "appid": "xxx",
  "appsecret": "xxx"
}

Complete workflow linkage

写文章(tech-writer/pm-writer) → 美化格式(formatter) → 推送到微信(本skill)

The user only needs to say three sentences:

  1. "Write an article about XXX"
  2. "Beautify the article"
  3. "Push to WeChat"