WeChat Official Account Draft Management

v1.0.6

WeChat Official Account Draft Box management tool. Create and manage graphic draft articles via WeChat API, supporting text and images. Automatically extract...

3· 1.9k·1 current·1 all-time
bymanifold@manifoldor

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for manifoldor/channel.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "WeChat Official Account Draft Management" (manifoldor/channel) from ClawHub.
Skill page: https://clawhub.ai/manifoldor/channel
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Required env vars: WECHAT_APPID, WECHAT_APPSECRET
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install channel

ClawHub CLI

Package manager switcher

npx clawhub@latest install channel
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description (WeChat draft management) match the implementation: the script talks to api.weixin.qq.com, uploads images, creates/list/publishes/deletes drafts and requires WECHAT_APPID/WECHAT_APPSECRET. Nothing requested appears unrelated to the stated purpose.
Instruction Scope
SKILL.md instructions are narrowly scoped: they tell the user to set WECHAT_APPID/WECHAT_APPSECRET, run the included script, and describe expected API interactions. The runtime instructions and the script operate only on local files (article text, images), the user's ~/.config/channel directory, and the official WeChat API endpoints.
Install Mechanism
There is no install spec or remote download; the package is instruction + an included Python script. No external archives, installers, or third-party package fetches are performed by the skill's metadata.
Credentials
The only environment variables referenced are WECHAT_APPID and WECHAT_APPSECRET (declared in SKILL.md and used by the script). These are the expected credentials for interacting with the WeChat API and are proportionate to the functionality.
Persistence & Privilege
The skill is not always-enabled, uses the default autonomous-invocation setting, and only creates its own config directory (~/.config/channel) and cache files (access_token.json, drafts_cache.json). It does not modify other skills or system-wide agent settings.
Assessment
This skill appears to do what it claims. Before installing: 1) Only provide WECHAT_APPID and WECHAT_APPSECRET from a trusted account; they are stored briefly and cached in ~/.config/channel/access_token.json. 2) The script writes files under ~/.config/channel and may create temporary image files when auto-generating covers; ensure that's acceptable. 3) Auto-cover generation uses the macOS 'sips' utility (may fail on other OSes). 4) Review the included scripts yourself if you want to double-check there is no additional network behavior; network calls in the code go to api.weixin.qq.com (official WeChat endpoints). 5) Keep your AppSecret secure and revoke/regenerate it if you suspect it was exposed.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

Environment variables
WECHAT_APPIDrequired
WECHAT_APPSECRETrequired
latestvk972w6h157s6yv5f1mtrh8m8s182rbj0
1.9kdownloads
3stars
4versions
Updated 1mo ago
v1.0.6
MIT-0

微信公众号草稿箱管理

通过微信公众号 API 管理草稿箱内容,支持创建图文消息、上传图片、发布文章。

功能特性

  • 📝 图文草稿 - 创建带格式的图文消息
  • 🖼️ 图片支持 - 自动上传正文和封面图片
  • 🎨 自动封面 - 未提供封面时自动生成默认封面图(蓝紫色渐变)
  • 📋 自动摘要 - 正文第一段自动提取为文章摘要
  • 📊 草稿管理 - 查看、发布、删除草稿
  • 🔗 发布接口 - 支持通过 API 发布(需权限)

前提条件

1. 微信公众号认证

  • 拥有一个微信公众号(订阅号或服务号)
  • 完成微信认证(部分接口需要)

2. 获取开发者凭证

  1. 登录 微信公众平台
  2. 开发 → 基本配置 → 开发者ID
  3. 获取 AppIDAppSecret
  4. 添加服务器 IP 到白名单

3. 配置环境变量

# 添加到 ~/.zshrc
export WECHAT_APPID="your-app-id"
export WECHAT_APPSECRET="your-app-secret"

然后执行:

source ~/.zshrc

使用方法

创建草稿

基础用法(自动生成封面图):

python3 scripts/channel.py create "文章标题" "这里是正文内容..."

从文件读取正文(自动生成封面图):

python3 scripts/channel.py create "文章标题" --file article.txt

带自定义封面图:

python3 scripts/channel.py create "文章标题" "正文内容..." --cover cover.jpg

禁止自动生成封面图:

python3 scripts/channel.py create "文章标题" "正文..." --no-auto-cover

设置作者:

python3 scripts/channel.py create "文章标题" "正文..." --author "张三"

正文格式

纯文本:

python3 scripts/channel.py create "标题" "这是正文内容,支持换行。\n\n第二段内容..."

带图片(Markdown 格式):

python3 scripts/channel.py create "标题" "正文\n\n!<span class=\"image\"><span>描述</span></span>(/path/to/image.jpg)\n\n更多内容..."

HTML 格式:

python3 scripts/channel.py create "标题" "<p>正文</p><img src='url' />"

查看草稿列表

# 列出最近 20 篇
python3 scripts/channel.py list

# 列出最近 50 篇
python3 scripts/channel.py list --limit 50

输出示例:

📝 草稿列表 (3 篇):

序号   Media ID                       标题                                     更新时间
----------------------------------------------------------------------------------------------------
1      MEDIA_ID_1234567890abcdef    欢迎使用微信公众号                         2024-02-03 15:30
2      MEDIA_ID_abcdef1234567890    文章标题示例                               2024-02-03 14:20
3      MEDIA_ID_xxxxxxxxxxxxxxxx    测试草稿                                   2024-02-03 13:10

发布草稿

python3 scripts/channel.py publish MEDIA_ID_1234567890abcdef

⚠️ 注意:发布接口需要开通发布权限,部分账号可能需要手动在后台发布。

删除草稿

python3 scripts/channel.py delete MEDIA_ID_1234567890abcdef

命令参考

命令功能示例
create创建草稿create "标题" "正文" --cover img.jpg
list列岀草稿list --limit 20
publish发布草稿publish media_id
delete删除草稿delete media_id

create 命令参数

参数简写说明必填
title-文章标题
content-正文内容否(可用 --file)
--file-f从文件读取正文
--author-a作者名称
--cover-c封面图片路径
--no-auto-cover-禁止自动生成封面图
--no-comment-关闭评论
--fans-only-仅粉丝可评论

自动封面图

当未提供 --cover 参数时,工具会自动生成一张默认封面图:

  • 尺寸: 900×500 像素(微信公众号推荐尺寸)
  • 样式: 蓝紫色渐变背景
  • 格式: JPEG
  • 提示: 自动生成时会显示 "🎨 未提供封面图,正在自动生成..."

如需使用自定义封面,请使用 --cover 参数指定图片路径。

正文内容格式

Markdown 支持

  • **粗体** → 粗体
  • *斜体* → 斜体
  • <span class="image"><span>描述</span></span>(路径) → 图片(自动上传)

图片处理

本地图片(自动上传):

!<span class="image"><span>图片描述</span></span>(/path/to/local/image.jpg)

网络图片(直接使用):

!<span class="image"><span>图片描述</span></span>(https://example.com/image.jpg)

摘要提取规则

  • 自动提取正文第一段作为摘要
  • 移除 HTML 标签
  • 超过 120 字符自动截断并添加 "..."
  • 用于文章列表展示和分享预览

输出结果

创建成功示例:

============================================================
✅ 草稿创建成功!
============================================================
📄 Media ID: MEDIA_ID_1234567890abcdef
📝 标题: 欢迎使用微信公众号
📋 摘要: 这是文章的摘要内容,来自正文第一段...
⏰ 创建时间: 2024-02-03T15:30:45.123456

💡 提示:
   - 草稿已保存到微信公众号后台
   - 请登录 mp.weixin.qq.com 查看并发布
   - 或使用 'publish' 命令直接发布(需开通权限)
============================================================

使用场景

场景1:快速发布文章

# 创建并准备发布
python3 scripts/channel.py create "今日新闻" "今天的重要新闻是..." --author "编辑部"

# 然后手动或自动发布
python3 scripts/channel.py list
python3 scripts/channel.py publish MEDIA_ID_xxxx

场景2:批量导入文章

# 准备多个文章文件
for file in articles/*.md; do
    title=$(head -1 "$file")
    python3 scripts/channel.py create "$title" --file "$file"
done

场景3:自动化发布流程

#!/bin/bash
# publish_daily.sh

TITLE="$(date +%Y年%m月%d日) 日报"
CONTENT=$(cat template.txt)

# 创建草稿
RESULT=$(python3 scripts/channel.py create "$TITLE" "$CONTENT" --cover daily_cover.jpg)

# 提取 Media ID 并发布(可选)
# MEDIA_ID=$(echo "$RESULT" | grep "Media ID:" | awk '{print $3}')
# python3 scripts/channel.py publish "$MEDIA_ID"

常见问题

错误:请设置环境变量 WECHAT_APPID 和 WECHAT_APPSECRET → 检查环境变量是否正确设置并生效

错误:access_token missing → 检查 AppID 和 AppSecret 是否正确 → 确认服务器 IP 已添加到公众号白名单

错误:api unauthorized → 公众号未认证,部分接口需要微信认证 → 订阅号和服务号权限不同

图片上传失败 → 检查图片路径是否正确 → 图片大小不能超过 10MB → 支持格式:jpg, png, gif

发布失败 → 确认已开通发布权限 → 部分账号需要手动在后台发布

API 限制

接口每日限制说明
获取 Access Token2000 次有效期 7200 秒
创建草稿100 篇草稿总数上限 100
上传图片无明确限制单张最大 10MB
发布无明确限制需要发布权限

注意事项

  1. 草稿数量 - 草稿箱最多保存 100 篇,超出需要删除旧草稿
  2. 图片存储 - 上传的图片存储在微信服务器,有有效期限制
  3. 内容审核 - 发布的内容需要符合微信内容规范
  4. 原创声明 - 可通过 API 声明原创(需额外参数)

参考

Comments

Loading comments...