Skip to content
Back to skills

Wechat Mp Publish

ASecurity

微信公众号文章发布工具 v1.0。基于官方 API,支持智能配图、模板渲染、草稿/发布双模式。当用户说\"发公众号\"、\"发布微信公众号\"时使用此技能。

  • 33 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added September 5, 2026
toolspythonbashapi

Works with

  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add dvcrn/openclaw-skills-marketplace --skill wechat-mp-publish --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Wechat Mp Publish?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Wechat Mp Publish
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dvcrn-wechat-mp-publish/badge)](https://www.skillsdirectory.com/skills/dvcrn-wechat-mp-publish)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: wechat-mp-publish
description: "微信公众号文章发布工具 v1.0。基于官方 API,支持智能配图、模板渲染、草稿/发布双模式。当用户说\"发公众号\"、\"发布微信公众号\"时使用此技能。"
---

# 微信公众号发布工具 v1.0

## 快速开始

### 1. 安装依赖
```bash
cd ~/.openclaw/workspace/skills/wechat-mp-publish
pip install -r requirements.txt
```

### 2. 配置公众号凭证
```bash
cp config.example.yaml config.yaml
# 编辑 config.yaml 填入 AppID 和 AppSecret
```

### 3. 运行测试
```bash
python publish.py --test
```

## 功能特性

### ✅ v1.0 已实现
- [x] 微信公众号 API 完整封装
- [x] access_token 自动缓存管理
- [x] 智能封面图生成(AI 绘图)
- [x] 3 种 HTML 样式模板
- [x] 草稿箱保存
- [x] 直接群发
- [x] 图片上传(获取正确 URL)
- [x] 配置管理(支持环境变量)

### 📋 使用命令

```bash
# 测试模式(自动发布 3 篇测试文章到草稿箱)
python publish.py --test

# 发布到草稿箱
python publish.py --draft "文章标题" "文章内容"

# 直接发布
python publish.py --publish "文章标题" "文章内容"

# 指定模板
python publish.py --draft "标题" "内容" --template business
```

### 🎨 模板样式

| 模板 | 风格 | 适用场景 |
|------|------|----------|
| `simple` | 简约 | 日常文章、技术文档 |
| `business` | 商务 | 正式公告、企业宣传 |
| `creative` | 创意 | 故事、随笔、创意内容 |

## 配置说明

### config.yaml
```yaml
wechat:
  appid: "你的 AppID"
  appsecret: "你的 AppSecret"
  name: "公众号名称"

image:
  provider: "dall-e-3"  # 或关闭 AI 绘图
  api_key: "${DALL_E_API_KEY}"  # 支持环境变量
```

### 环境变量
```bash
export DALL_E_API_KEY="sk-..."  # DALL-E 3 API 密钥
```

## API 说明

### 核心类

**WeChatAPI** - 微信 API 封装
- `get_access_token()` - 获取访问令牌
- `upload_image()` - 上传图片
- `create_draft()` - 创建草稿
- `publish_all()` - 群发消息

**ImageGenerator** - 图片生成
- `generate_cover()` - 生成封面图
- `extract_keywords()` - 提取关键词
- `build_prompt()` - 构建绘图提示词

## 测试任务

### 验收标准
- [x] API 连接成功
- [ ] 生成 3 篇测试文章到草稿箱
- [ ] 每篇文章配图正确
- [ ] 3 个模板样式正常显示

### 测试内容
主题:**"我的诞生记"**
- 以 AI 助手视角描述从诞生到成长的历程
- 每篇文章使用不同模板
- 每篇配图 1 张(AI 生成)

## 故障排除

### 问题 1: invalid appid
**原因**: AppID 配置错误
**解决**: 检查 config.yaml 中的 appid 是否正确

### 问题 2: invalid appsecret
**原因**: AppSecret 配置错误
**解决**: 检查 appsecret,注意不要有多余空格

### 问题 3: 图片上传失败
**原因**: 图片格式或大小不符合要求
**解决**: 确保图片为 JPG/PNG,大小<2MB

### 问题 4: AI 绘图失败
**原因**: DALL-E API 密钥未配置
**解决**: 设置 DALL_E_API_KEY 环境变量或使用占位图

## 版本历史

### v1.0.0 (2026-03-09)
- 初始版本发布
- 实现核心发布功能
- 集成 AI 智能配图
- 3 种 HTML 模板

## 相关文档
- [产品需求文档](PRD.md)
- [配置示例](config.example.yaml)

Files in this skill

  • OWASP_SECURITY_AUDIT_REPORT.md27.9 KB
  • PRD.md4.4 KB
  • README.md6.3 KB
  • SECURITY_AUDIT_20260312.md16 KB
  • SKILL.md3.2 KB
  • USER_GUIDE.md11 KB
  • VERSION.md1.3 KB
  • cleanup_logs.py2.1 KB
  • cleanup_secrets.py4.7 KB
  • config.example.yaml2.9 KB
  • config.yaml4.8 KB
  • config_manager.py8.2 KB
  • image_gen.py50.3 KB
  • publish.js10.8 KB
  • publish.py31.2 KB
  • requirements.txt394 B
  • templates/simple_minimal.html1.6 KB
  • test_report.json1.9 KB
  • tests/README.md2.7 KB
  • tests/__init__.py461 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.