yishan

WeChat Official Account Draft Management

Business Opsv1.0.6
By yishanUpdated 2026-05-114 versions · latest released 2026-03-12channel@clawhub_alphafactor/channel
E-commerceUser Operations#WeChat#微信

According to AlphaMoat, as of 2026-09, WeChat Official Account Draft Management has 3,300 downloads and 4 stars — ranked #3,433 of 5,078 AI skills overall, and #189 of 297 in Business Ops.

Installs
352
Downloads
3.3K
Stars
4
Overall Rank
#3,433
Top 68% overall · Top 64% in Business Ops
PlatformInstallsDownloadsStarsComments
ClawHub ↗892.7K3-
SkillHub ↗3523.3K4—

Platforms count differently and update at different times.

What this skill does

It covers body and cover uploads, default covers, first-paragraph summaries, draft listing, publishing and deletion. It requires WECHAT_APPID, WECHAT_APPSECRET, an allowlisted server IP and relevant API permissions; some accounts need manual publication. Protect credentials and local token caches, and confirm the account, media_id and intended action before publishing or deleting.

Profile published 2026-10-27

What you can do with it

  • Prepare WeChat Official Account drafts

When to use it

  • When an authorized WeChat account needs API-based draft management

Example prompts

Generated from the skill’s documentation as examples; not results of actual runs.

Prepare a draft plan for this article, check its cover and summary, and verify the account, draft identifier and permissions before publication.

Monthly Trend

Downloads3.3K
2.2K2.8K3.4K2026-03 · Downloads 2.2K2026-05 · Downloads 2.5K2026-06 · Downloads 2.6K2026-07 · Downloads 2.8K2026-08 · Downloads 2.9K2026-09 · Downloads 3.3K26-0326-09
Stars4
3442026-03 · Stars 32026-05 · Stars 42026-06 · Stars 42026-07 · Stars 42026-08 · Stars 42026-09 · Stars 426-0326-09

The counting method changed in 2026-09: skills with the same name are now counted separately by author, and the full catalog is covered. Dashed lines show months before the change; they are not compared with later months, and no growth is computed across the change.

MonthDownloadsMoMStars
2026-093.3K—4
2026-082.9K+3.2%4
2026-072.8K+5.5%4
2026-062.6K+3.4%4
2026-052.5K—4
2026-032.2K—3

SKILL.md (original)

The author’s original file, shown as plain text without edits or review by AlphaMoat. Links are not clickable; check commands before running them. Fetched 2026-10-23.

8.2 KB · ClawHub v1.0.6
---
name: channel
description: WeChat Official Account Draft Box management tool. Create and manage graphic draft articles via WeChat API, supporting text and images. Automatically extracts the first paragraph as summary. Supports draft creation, listing, publishing, and deletion.
env:
  - WECHAT_APPID
  - WECHAT_APPSECRET
---

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

## 功能特性

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

## 前提条件

### 1. 微信公众号认证

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

### 2. 获取开发者凭证

1. 登录 [微信公众平台](https://mp.weixin.qq.com)
2. 开发 → 基本配置 → 开发者ID
3. 获取 **AppID** 和 **AppSecret**
4. 添加服务器 IP 到白名单

### 3. 配置环境变量

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

然后执行:
```bash
source ~/.zshrc
```

## 使用方法

### 创建草稿

**基础用法(自动生成封面图):**
```bash
python3 scripts/channel.py create "文章标题" "这里是正文内容..."
```

**从文件读取正文(自动生成封面图):**
```bash
python3 scripts/channel.py create "文章标题" --file article.txt
```

**带自定义封面图:**
```bash
python3 scripts/channel.py create "文章标题" "正文内容..." --cover cover.jpg
```

**禁止自动生成封面图:**
```bash
python3 scripts/channel.py create "文章标题" "正文..." --no-auto-cover
```

**设置作者:**
```bash
python3 scripts/channel.py create "文章标题" "正文..." --author "张三"
```

### 正文格式

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

**带图片(Markdown 格式):**
```bash
python3 scripts/channel.py create "标题" "正文\n\n!<span class=\"image\"><span>描述</span></span>(/path/to/image.jpg)\n\n更多内容..."
```

**HTML 格式:**
```bash
python3 scripts/channel.py create "标题" "<p>正文</p><img src='url' />"
```

### 查看草稿列表

```bash
# 列出最近 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
```

### 发布草稿

```bash
python3 scripts/channel.py publish MEDIA_ID_1234567890abcdef
```

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

### 删除草稿

```bash
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>(路径)` → 图片(自动上传)

### 图片处理

**本地图片(自动上传):**
```markdown
!<span class="image"><span>图片描述</span></span>(/path/to/local/image.jpg)
```

**网络图片(直接使用):**
```markdown
!<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:快速发布文章

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

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

### 场景2:批量导入文章

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

### 场景3:自动化发布流程

```bash
#!/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 Token | 2000 次 | 有效期 7200 秒 |
| 创建草稿 | 100 篇 | 草稿总数上限 100 |
| 上传图片 | 无明确限制 | 单张最大 10MB |
| 发布 | 无明确限制 | 需要发布权限 |

## 注意事项

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

## 参考

- 微信公众号文档: https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html
- 草稿箱接口: [references/wechat_api.md](references/wechat_api.md)
- 微信公众平台: https://mp.weixin.qq.com

Popular in Business Ops

More from yishan

Data month: 2026-09 · Downloads, stars and installs are aggregated monthly from public skill registries (ClawHub, SkillHub). See methodology.