Back to search
wechat-publisher-pro
SkillWorks with Claude CodeGitHub
微信公众号文章自动生成封面、专业排版、一键发布技能。支持AI生成封面、小红书格式排版、自动上传到草稿箱。当用户提到"公众号发布"、"微信文章排版"、"生成封面"、"发布到公众号"时触发。
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Checked today
Badge for your README
Markdown
[](/listings/readarkclub--wechat-publisher-pro)HTML
<a href="/listings/readarkclub--wechat-publisher-pro"><img src="/api/listings/readarkclub--wechat-publisher-pro/badge.svg" alt="findsafeskills safety rating" /></a>Install
i
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
SKILL.md · Manifest · 237 lines
- ---
- name: wechat-publisher-pro
- description: 微信公众号文章自动生成封面、专业排版、一键发布技能。支持AI生成封面、小红书格式排版、自动上传到草稿箱。当用户提到"公众号发布"、"微信文章排版"、"生成封面"、"发布到公众号"时触发。
- version: 1.0.0
- author: AutoClaw
- tags:
- - publishing
- - formatting
- - cover-generation
- - automation
- ---
- # 微信公众号自动发布技能
- 专业的公众号文章生成、排版、发布一体化工具。支持AI生成封面、专业排版、一键发布到草稿箱。
- ## ✨ 核心功能
- ### 1. AI封面生成
- - 智谱AI CogView-3(推荐,10-20秒)
- - Gemini 3.1 Pro Image Preview
- - 本地PowerShell生成(1-2秒)
- ### 2. 专业排版
- - **增强版排版工具** - 支持小红书格式
- - 智能识别emoji标题
- - 保留所有emoji
- - 丰富视觉组件(对比列表、分割线、金句区块)
- - **标准排版工具** - 标准Markdown格式
- ### 3. 一键发布
- - 自动上传封面到永久素材库
- - 创建草稿到公众号后台
- - 支持预览和验证
- ## 🚀 快速开始
- ### 安装
- ```bash
- # 克隆仓库
- git clone https://github.com/your-username/wechat-publisher-pro.git
- cd wechat-publisher-pro
- # 安装依赖
- pip install -r requirements.txt
- # 配置环境变量
- cp .env.example .env
- # 编辑.env文件,填入你的配置
- ```
- ### 配置
- 创建 `.env` 文件:
- ```bash
- # 微信公众号配置
- WECHAT_APPID=your_app_id_here
- WECHAT_SECRET=your_app_secret_here
- # AI模型配置
- ZHIPU_API_KEY=your_zhipu_api_key_here
- GOOGLE_API_KEY=your_gemini_api_key_here # 可选
- ```
- ### 使用
- #### 完整流程(推荐)
- ```python
- from scripts.wechat_publisher import WeChatPublisher
- # 初始化发布器
- publisher = WeChatPublisher()
- # 发布文章(自动生成封面+排版+发布)
- result = publisher.publish(
- markdown_file="article.md",
- author="Your Name"
- )
- print(f"草稿ID: {result['draft_id']}")
- ```
- #### 分步执行
- ```python
- # 1. 生成封面
- from scripts.cover_generator_unified import UnifiedCoverGenerator
- generator = UnifiedCoverGenerator()
- cover_path = generator.generate(
- prompt="A tech cover for AI article",
- output_path="cover.png"
- )
- # 2. 上传封面
- from scripts.wechat_upload_cover import upload_cover
- media_id = upload_cover(cover_path)
- # 3. 排版文章
- from scripts.wechat_typesetter_enhanced import WeChatTypesetterEnhanced
- typesetter = WeChatTypesetterEnhanced()
- html = typesetter.format_xiaohongshu(markdown_content)
- # 4. 发布到微信
- from scripts.publish_enhanced_to_wechat import publish_to_wechat
- draft_id = publish_to_wechat(
- title="文章标题",
- content=html,
- cover_media_id=media_id
- )
- ```
- ## 📂 文件结构
- ```
- wechat-publisher-pro/
- ├── SKILL.md # 技能定义文件
- ├── README.md # 使用说明
- ├── .env.example # 环境变量示例
- ├── .gitignore # Git忽略文件
- ├── requirements.txt # Python依赖
- ├── scripts/ # 脚本工具
- │ ├── wechat_publisher.py # 统一发布接口
- │ ├── wechat_typesetter_enhanced.py # 增强版排版工具
- │ ├── cover_generator_unified.py # 统一封面生成器
- │ ├── wechat_upload_cover.py # 封面上传工具
- │ └── publish_enhanced_to_wechat.py # 增强版发布脚本
- ├── templates/ # 模板文件
- │ ├── blue-minimal.html # 蓝色杂志风模板
- │ └── dark-tech.html # 暗黑科技风模板
- ├── examples/ # 示例文件
- │ ├── xiaohongshu_example.md # 小红书格式示例
- │ └── standard_example.md # 标准Markdown示例
- └── docs/ # 文档
- ├── EXPERIENCE.md # 使用经验
- └── TROUBLESHOOTING.md # 故障排查
- ```
- ## 🎨 排版效果
- ### 小红书格式支持
- **支持的特殊格式**:
- - ✅ Emoji标题(🎯💡🚀💰📊)
- - ✅ Emoji分割线(━━━━)
- - ✅ 对比列表(✅/❌彩色显示)
- - ✅ 金句区块(蓝色背景)
- **示例**:
- ```markdown
- 🎯 章节标题
- ❌ 旧方式:30分钟
- ✅ 新方式:5分钟
- ━━━━━━━━━━━━━━━━━━
- 💡 金句内容
- ```
- ## ⚙️ 高级配置
- ### 环境变量
- | 变量名 | 必需 | 说明 |
- |--------|------|------|
- | `WECHAT_APPID` | ✅ | 微信公众号AppID |
- | `WECHAT_SECRET` | ✅ | 微信公众号AppSecret |
- | `ZHIPU_API_KEY` | ⚠️ | 智谱AI API Key(封面生成) |
- | `GOOGLE_API_KEY` | ❌ | Gemini API Key(可选) |
- ### IP白名单
- **重要**:需要在公众号后台配置IP白名单
- ```bash
- # 检查当前IP
- curl https://api.ipify.org
- # 添加到白名单
- 公众号后台 → 开发 → 基本配置 → IP白名单
- ```
- ## 🔧 故障排查
- ### 常见错误
- #### 1. IP不在白名单(40164)
- ```
- 错误:invalid ip xxx.xxx.xxx.xxx
- 解决:在公众号后台添加当前IP到白名单
- ```
- #### 2. 无效media_id(40007)
- ```
- 错误:invalid media_id
- 原因:使用了临时素材而非永久素材
- 解决:确保使用永久素材接口上传
- ```
- #### 3. 摘要超长(45004)
- ```
- 错误:description size out of limit
- 解决:摘要限制在80字以内
- ```
- ## 📊 性能指标
- | 操作 | 平均耗时 |
- |------|---------|
- | 封面生成(智谱AI) | 10-20秒 |
- | 封面上传 | 2-5秒 |
- | 排版 | 1秒 |
- | 创建草稿 | 2-3秒 |
- | **总耗时** | **15-30秒** |
- ## 📄 许可证
- MIT License
- ## 🙏 致谢
- - [wechat-typesetting-cy](https://github.com/CY-CHENYUE/wechat-typesetting-cy) - 排版技能灵感
- - [智谱AI](https://open.bigmodel.cn/) - 封面生成API
- ---
- **维护者**: AutoClaw 🦞
- **版本**: 1.0.0
- **最后更新**: 2026-03-26
README.md · README · 322 lines
- # 微信公众号自动发布技能
- [](https://opensource.org/licenses/MIT)
- [](https://www.python.org/downloads/)
- 专业的公众号文章生成、排版、发布一体化工具。支持AI生成封面、小红书格式排版、一键发布到草稿箱。
- ## ✨ 核心功能
- - 🎨 **AI封面生成** - 智谱AI/Gemini/本地生成
- - 📝 **专业排版** - 支持小红书emoji格式
- - 🚀 **一键发布** - 自动上传+创建草稿
- - ⚡ **快速高效** - 15-30秒完成全流程
- ## 🚀 快速开始
- ### 1. 克隆仓库
- ```bash
- git clone https://github.com/your-username/wechat-publisher-pro.git
- cd wechat-publisher-pro
- ```
- ### 2. 安装依赖
- ```bash
- pip install -r requirements.txt
- ```
- ### 3. 配置环境变量
- ```bash
- cp .env.example .env
- # 编辑.env文件,填入你的配置
- ```
- `.env` 文件内容:
- ```bash
- # 微信公众号配置(必需)
- WECHAT_APPID=your_app_id_here
- WECHAT_SECRET=your_app_secret_here
- # 智谱AI配置(封面生成,推荐)
- ZHIPU_API_KEY=your_zhipu_api_key_here
- # Gemini配置(可选)
- GOOGLE_API_KEY=your_gemini_api_key_here
- ```
- ### 4. 配置IP白名单
- **重要**:需要在公众号后台配置IP白名单
- ```bash
- # 检查当前IP
- curl https://api.ipify.org
- # 添加到白名单
- 公众号后台 → 开发 → 基本配置 → IP白名单 → 添加你的IP
- ```
- ### 5. 运行示例
- ```bash
- # 完整流程示例
- python examples/full_workflow.py
- # 分步示例
- python examples/step_by_step.py
- ```
- ## 📖 使用指南
- ### 方式1:统一发布(推荐)
- ```python
- from scripts.wechat_publisher import WeChatPublisher
- publisher = WeChatPublisher()
- result = publisher.publish(
- markdown_file="article.md",
- author="Your Name"
- )
- print(f"草稿ID: {result['draft_id']}")
- ```
- ### 方式2:分步执行
- ```python
- # 1. 生成封面
- from scripts.cover_generator_unified import UnifiedCoverGenerator
- generator = UnifiedCoverGenerator()
- cover_path = generator.generate(
- prompt="Tech cover for AI article",
- output_path="cover.png"
- )
- # 2. 上传封面
- from scripts.wechat_upload_cover import upload_cover
- media_id = upload_cover(cover_path)
- # 3. 排版文章
- from scripts.wechat_typesetter_enhanced import WeChatTypesetterEnhanced
- typesetter = WeChatTypesetterEnhanced()
- html = typesetter.format_xiaohongshu(markdown_content)
- # 4. 发布到微信
- from scripts.publish_enhanced_to_wechat import publish_to_wechat
- draft_id = publish_to_wechat(
- title="文章标题",
- content=html,
- cover_media_id=media_id
- )
- ```
- ## 🎨 排版效果
- ### 小红书格式支持
- **输入**:
- ```markdown
- 🎯 章节标题
- ❌ 旧方式:30分钟
- ✅ 新方式:5分钟
- ━━━━━━━━━━━━━━━━━━
- 💡 金句内容
- ```
- **输出**:
- - 🎯 **章节标题**(26px加粗)
- - ❌ 旧方式(红色)
- - ✅ 新方式(绿色)
- - 蓝色分割线
- - 💡 金句区块(蓝底白字)
- ## 📂 文件结构
- ```
- wechat-publisher-pro/
- ├── SKILL.md # 技能定义
- ├── README.md # 使用说明
- ├── .env.example # 环境变量示例
- ├── .gitignore # Git忽略文件
- ├── requirements.txt # Python依赖
- ├── scripts/ # 核心脚本
- │ ├── wechat_publisher.py # 统一发布接口
- │ ├── wechat_typesetter_enhanced.py # 增强版排版
- │ ├── cover_generator_unified.py # 封面生成器
- │ ├── wechat_upload_cover.py # 封面上传
- │ └── publish_enhanced_to_wechat.py # 发布脚本
- ├── examples/ # 示例文件
- │ ├── full_workflow.py # 完整流程
- │ ├── step_by_step.py # 分步执行
- │ ├── xiaohongshu_example.md # 小红书示例
- │ └── standard_example.md # 标准示例
- └── docs/ # 文档
- ├── EXPERIENCE.md # 使用经验
- └── TROUBLESHOOTING.md # 故障排查
- ```
- ## ⚙️ 配置说明
- ### 环境变量
- | 变量名 | 必需 | 说明 |
- |--------|------|------|
- | `WECHAT_APPID` | ✅ | 微信公众号AppID |
- | `WECHAT_SECRET` | ✅ | 微信公众号AppSecret |
- | `ZHIPU_API_KEY` | ⚠️ | 智谱AI API Key(封面生成) |
- | `GOOGLE_API_KEY` | ❌ | Gemini API Key(可选) |
- ### 获取配置
- #### 微信公众号
- 1. 登录[公众号后台](https://mp.weixin.qq.com)
- 2. 开发 → 基本配置
- 3. 复制AppID和AppSecret
- #### 智谱AI
- 1. 访问[智谱AI开放平台](https://open.bigmodel.cn/)
- 2. 注册并创建API Key
- ## 🔧 故障排查
- ### IP不在白名单(40164)
- ```bash
- # 检查当前IP
- curl https://api.ipify.org
- # 添加到白名单
- 公众号后台 → 开发 → 基本配置 → IP白名单
- ```
- ### 无效media_id(40007)
- **原因**:使用了临时素材而非永久素材
- **解决**:确保使用 `/material/add_material` 接口
- ### 摘要超长(45004)
- **解决**:摘要限制在80字以内
- ```python
- digest = plain_text[:80] + '...'
- ```
- ### 排版内容为空
- **原因**:文章格式不支持
- **解决**:使用增强版排版工具
- ```python
- # ❌ 标准
- from scripts.wechat_typesetter import WeChatTypesetter
- # ✅ 增强版(支持小红书)
- from scripts.wechat_typesetter_enhanced import WeChatTypesetterEnhanced
- ```
- ## 📊 性能指标
- | 操作 | 平均耗时 |
- |------|---------|
- | 封面生成(智谱AI) | 10-20秒 |
- | 封面生成(本地) | 1-2秒 |
- | 封面上传 | 2-5秒 |
- | 排版 | 1秒 |
- | 创建草稿 | 2-3秒 |
- | **总耗时** | **15-30秒** |
- ## 🎓 最佳实践
- ### 封面生成
- ```python
- # 好的提示词
- prompt = "A tech cover for AI article, gradient blue background, robotic teamwork"
- # 避免模糊描述
- # ❌ prompt = "A cover"
- ```
- ### 排版选择
- ```python
- # 小红书格式
- if "🎯" in content or "✅" in content:
- typesetter = WeChatTypesetterEnhanced()
- # 标准Markdown
- else:
- typesetter = WeChatTypesetter()
- ```
- ### 发布流程
- ```python
- # 1. 先预览HTML
- html = typesetter.format(content)
- with open("preview.html", "w") as f:
- f.write(html)
- # 2. 检查摘要
- if len(digest) > 80:
- digest = digest[:80] + "..."
- # 3. 确认IP
- current_ip = get_current_ip()
- if current_ip != configured_ip:
- update_whitelist(current_ip)
- ```
- ## 🤝 贡献
- 欢迎提交Issue和Pull Request!
- ### 开发环境
- ```bash
- git clone https://github.com/your-username/wechat-publisher-pro.git
- cd wechat-publisher-pro
- pip install -r requirements.txt
- cp .env.example .env
- # 编辑.env
- ```
- ### 测试
- ```bash
- python -m pytest tests/
- ```
- ## 📄 许可证
- [MIT License](LICENSE)
- ## 🙏 致谢
- - [wechat-typesetting-cy](https://github.com/CY-CHENYUE/wechat-typesetting-cy) - 排版技能灵感
- - [智谱AI](https://open.bigmodel.cn/) - 封面生成API
- ## 📮 联系方式
- - Issue: [GitHub Issues](https://github.com/your-username/wechat-publisher-pro/issues)
- - Email: your-email@example.com
- ---
- **维护者**: AutoClaw 🦞
- **版本**: 1.0.0
- **最后更新**: 2026-03-26
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.