Skip to content
Back to search

wechat-publisher-pro

微信公众号文章自动生成封面、专业排版、一键发布技能。支持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
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/readarkclub--wechat-publisher-pro/badge.svg)](/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
  1. ---
  2. name: wechat-publisher-pro
  3. description: 微信公众号文章自动生成封面、专业排版、一键发布技能。支持AI生成封面、小红书格式排版、自动上传到草稿箱。当用户提到"公众号发布"、"微信文章排版"、"生成封面"、"发布到公众号"时触发。
  4. version: 1.0.0
  5. author: AutoClaw
  6. tags:
  7. - wechat
  8. - publishing
  9. - formatting
  10. - cover-generation
  11. - automation
  12. ---
  13. # 微信公众号自动发布技能
  14. 专业的公众号文章生成、排版、发布一体化工具。支持AI生成封面、专业排版、一键发布到草稿箱。
  15. ## ✨ 核心功能
  16. ### 1. AI封面生成
  17. - 智谱AI CogView-3(推荐,10-20秒)
  18. - Gemini 3.1 Pro Image Preview
  19. - 本地PowerShell生成(1-2秒)
  20. ### 2. 专业排版
  21. - **增强版排版工具** - 支持小红书格式
  22. - 智能识别emoji标题
  23. - 保留所有emoji
  24. - 丰富视觉组件(对比列表、分割线、金句区块)
  25. - **标准排版工具** - 标准Markdown格式
  26. ### 3. 一键发布
  27. - 自动上传封面到永久素材库
  28. - 创建草稿到公众号后台
  29. - 支持预览和验证
  30. ## 🚀 快速开始
  31. ### 安装
  32. ```bash
  33. # 克隆仓库
  34. git clone https://github.com/your-username/wechat-publisher-pro.git
  35. cd wechat-publisher-pro
  36. # 安装依赖
  37. pip install -r requirements.txt
  38. # 配置环境变量
  39. cp .env.example .env
  40. # 编辑.env文件,填入你的配置
  41. ```
  42. ### 配置
  43. 创建 `.env` 文件:
  44. ```bash
  45. # 微信公众号配置
  46. WECHAT_APPID=your_app_id_here
  47. WECHAT_SECRET=your_app_secret_here
  48. # AI模型配置
  49. ZHIPU_API_KEY=your_zhipu_api_key_here
  50. GOOGLE_API_KEY=your_gemini_api_key_here # 可选
  51. ```
  52. ### 使用
  53. #### 完整流程(推荐)
  54. ```python
  55. from scripts.wechat_publisher import WeChatPublisher
  56. # 初始化发布器
  57. publisher = WeChatPublisher()
  58. # 发布文章(自动生成封面+排版+发布)
  59. result = publisher.publish(
  60. markdown_file="article.md",
  61. author="Your Name"
  62. )
  63. print(f"草稿ID: {result['draft_id']}")
  64. ```
  65. #### 分步执行
  66. ```python
  67. # 1. 生成封面
  68. from scripts.cover_generator_unified import UnifiedCoverGenerator
  69. generator = UnifiedCoverGenerator()
  70. cover_path = generator.generate(
  71. prompt="A tech cover for AI article",
  72. output_path="cover.png"
  73. )
  74. # 2. 上传封面
  75. from scripts.wechat_upload_cover import upload_cover
  76. media_id = upload_cover(cover_path)
  77. # 3. 排版文章
  78. from scripts.wechat_typesetter_enhanced import WeChatTypesetterEnhanced
  79. typesetter = WeChatTypesetterEnhanced()
  80. html = typesetter.format_xiaohongshu(markdown_content)
  81. # 4. 发布到微信
  82. from scripts.publish_enhanced_to_wechat import publish_to_wechat
  83. draft_id = publish_to_wechat(
  84. title="文章标题",
  85. content=html,
  86. cover_media_id=media_id
  87. )
  88. ```
  89. ## 📂 文件结构
  90. ```
  91. wechat-publisher-pro/
  92. ├── SKILL.md # 技能定义文件
  93. ├── README.md # 使用说明
  94. ├── .env.example # 环境变量示例
  95. ├── .gitignore # Git忽略文件
  96. ├── requirements.txt # Python依赖
  97. ├── scripts/ # 脚本工具
  98. │ ├── wechat_publisher.py # 统一发布接口
  99. │ ├── wechat_typesetter_enhanced.py # 增强版排版工具
  100. │ ├── cover_generator_unified.py # 统一封面生成器
  101. │ ├── wechat_upload_cover.py # 封面上传工具
  102. │ └── publish_enhanced_to_wechat.py # 增强版发布脚本
  103. ├── templates/ # 模板文件
  104. │ ├── blue-minimal.html # 蓝色杂志风模板
  105. │ └── dark-tech.html # 暗黑科技风模板
  106. ├── examples/ # 示例文件
  107. │ ├── xiaohongshu_example.md # 小红书格式示例
  108. │ └── standard_example.md # 标准Markdown示例
  109. └── docs/ # 文档
  110. ├── EXPERIENCE.md # 使用经验
  111. └── TROUBLESHOOTING.md # 故障排查
  112. ```
  113. ## 🎨 排版效果
  114. ### 小红书格式支持
  115. **支持的特殊格式**:
  116. - ✅ Emoji标题(🎯💡🚀💰📊)
  117. - ✅ Emoji分割线(━━━━)
  118. - ✅ 对比列表(✅/❌彩色显示)
  119. - ✅ 金句区块(蓝色背景)
  120. **示例**:
  121. ```markdown
  122. 🎯 章节标题
  123. ❌ 旧方式:30分钟
  124. ✅ 新方式:5分钟
  125. ━━━━━━━━━━━━━━━━━━
  126. 💡 金句内容
  127. ```
  128. ## ⚙️ 高级配置
  129. ### 环境变量
  130. | 变量名 | 必需 | 说明 |
  131. |--------|------|------|
  132. | `WECHAT_APPID` | ✅ | 微信公众号AppID |
  133. | `WECHAT_SECRET` | ✅ | 微信公众号AppSecret |
  134. | `ZHIPU_API_KEY` | ⚠️ | 智谱AI API Key(封面生成) |
  135. | `GOOGLE_API_KEY` | ❌ | Gemini API Key(可选) |
  136. ### IP白名单
  137. **重要**:需要在公众号后台配置IP白名单
  138. ```bash
  139. # 检查当前IP
  140. curl https://api.ipify.org
  141. # 添加到白名单
  142. 公众号后台 → 开发 → 基本配置 → IP白名单
  143. ```
  144. ## 🔧 故障排查
  145. ### 常见错误
  146. #### 1. IP不在白名单(40164)
  147. ```
  148. 错误:invalid ip xxx.xxx.xxx.xxx
  149. 解决:在公众号后台添加当前IP到白名单
  150. ```
  151. #### 2. 无效media_id(40007)
  152. ```
  153. 错误:invalid media_id
  154. 原因:使用了临时素材而非永久素材
  155. 解决:确保使用永久素材接口上传
  156. ```
  157. #### 3. 摘要超长(45004)
  158. ```
  159. 错误:description size out of limit
  160. 解决:摘要限制在80字以内
  161. ```
  162. ## 📊 性能指标
  163. | 操作 | 平均耗时 |
  164. |------|---------|
  165. | 封面生成(智谱AI) | 10-20秒 |
  166. | 封面上传 | 2-5秒 |
  167. | 排版 | 1秒 |
  168. | 创建草稿 | 2-3秒 |
  169. | **总耗时** | **15-30秒** |
  170. ## 📄 许可证
  171. MIT License
  172. ## 🙏 致谢
  173. - [wechat-typesetting-cy](https://github.com/CY-CHENYUE/wechat-typesetting-cy) - 排版技能灵感
  174. - [智谱AI](https://open.bigmodel.cn/) - 封面生成API
  175. ---
  176. **维护者**: AutoClaw 🦞
  177. **版本**: 1.0.0
  178. **最后更新**: 2026-03-26
README.md · README · 322 lines
  1. # 微信公众号自动发布技能
  2. [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
  3. [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
  4. 专业的公众号文章生成、排版、发布一体化工具。支持AI生成封面、小红书格式排版、一键发布到草稿箱。
  5. ## ✨ 核心功能
  6. - 🎨 **AI封面生成** - 智谱AI/Gemini/本地生成
  7. - 📝 **专业排版** - 支持小红书emoji格式
  8. - 🚀 **一键发布** - 自动上传+创建草稿
  9. - ⚡ **快速高效** - 15-30秒完成全流程
  10. ## 🚀 快速开始
  11. ### 1. 克隆仓库
  12. ```bash
  13. git clone https://github.com/your-username/wechat-publisher-pro.git
  14. cd wechat-publisher-pro
  15. ```
  16. ### 2. 安装依赖
  17. ```bash
  18. pip install -r requirements.txt
  19. ```
  20. ### 3. 配置环境变量
  21. ```bash
  22. cp .env.example .env
  23. # 编辑.env文件,填入你的配置
  24. ```
  25. `.env` 文件内容:
  26. ```bash
  27. # 微信公众号配置(必需)
  28. WECHAT_APPID=your_app_id_here
  29. WECHAT_SECRET=your_app_secret_here
  30. # 智谱AI配置(封面生成,推荐)
  31. ZHIPU_API_KEY=your_zhipu_api_key_here
  32. # Gemini配置(可选)
  33. GOOGLE_API_KEY=your_gemini_api_key_here
  34. ```
  35. ### 4. 配置IP白名单
  36. **重要**:需要在公众号后台配置IP白名单
  37. ```bash
  38. # 检查当前IP
  39. curl https://api.ipify.org
  40. # 添加到白名单
  41. 公众号后台 → 开发 → 基本配置 → IP白名单 → 添加你的IP
  42. ```
  43. ### 5. 运行示例
  44. ```bash
  45. # 完整流程示例
  46. python examples/full_workflow.py
  47. # 分步示例
  48. python examples/step_by_step.py
  49. ```
  50. ## 📖 使用指南
  51. ### 方式1:统一发布(推荐)
  52. ```python
  53. from scripts.wechat_publisher import WeChatPublisher
  54. publisher = WeChatPublisher()
  55. result = publisher.publish(
  56. markdown_file="article.md",
  57. author="Your Name"
  58. )
  59. print(f"草稿ID: {result['draft_id']}")
  60. ```
  61. ### 方式2:分步执行
  62. ```python
  63. # 1. 生成封面
  64. from scripts.cover_generator_unified import UnifiedCoverGenerator
  65. generator = UnifiedCoverGenerator()
  66. cover_path = generator.generate(
  67. prompt="Tech cover for AI article",
  68. output_path="cover.png"
  69. )
  70. # 2. 上传封面
  71. from scripts.wechat_upload_cover import upload_cover
  72. media_id = upload_cover(cover_path)
  73. # 3. 排版文章
  74. from scripts.wechat_typesetter_enhanced import WeChatTypesetterEnhanced
  75. typesetter = WeChatTypesetterEnhanced()
  76. html = typesetter.format_xiaohongshu(markdown_content)
  77. # 4. 发布到微信
  78. from scripts.publish_enhanced_to_wechat import publish_to_wechat
  79. draft_id = publish_to_wechat(
  80. title="文章标题",
  81. content=html,
  82. cover_media_id=media_id
  83. )
  84. ```
  85. ## 🎨 排版效果
  86. ### 小红书格式支持
  87. **输入**:
  88. ```markdown
  89. 🎯 章节标题
  90. ❌ 旧方式:30分钟
  91. ✅ 新方式:5分钟
  92. ━━━━━━━━━━━━━━━━━━
  93. 💡 金句内容
  94. ```
  95. **输出**:
  96. - 🎯 **章节标题**(26px加粗)
  97. - ❌ 旧方式(红色)
  98. - ✅ 新方式(绿色)
  99. - 蓝色分割线
  100. - 💡 金句区块(蓝底白字)
  101. ## 📂 文件结构
  102. ```
  103. wechat-publisher-pro/
  104. ├── SKILL.md # 技能定义
  105. ├── README.md # 使用说明
  106. ├── .env.example # 环境变量示例
  107. ├── .gitignore # Git忽略文件
  108. ├── requirements.txt # Python依赖
  109. ├── scripts/ # 核心脚本
  110. │ ├── wechat_publisher.py # 统一发布接口
  111. │ ├── wechat_typesetter_enhanced.py # 增强版排版
  112. │ ├── cover_generator_unified.py # 封面生成器
  113. │ ├── wechat_upload_cover.py # 封面上传
  114. │ └── publish_enhanced_to_wechat.py # 发布脚本
  115. ├── examples/ # 示例文件
  116. │ ├── full_workflow.py # 完整流程
  117. │ ├── step_by_step.py # 分步执行
  118. │ ├── xiaohongshu_example.md # 小红书示例
  119. │ └── standard_example.md # 标准示例
  120. └── docs/ # 文档
  121. ├── EXPERIENCE.md # 使用经验
  122. └── TROUBLESHOOTING.md # 故障排查
  123. ```
  124. ## ⚙️ 配置说明
  125. ### 环境变量
  126. | 变量名 | 必需 | 说明 |
  127. |--------|------|------|
  128. | `WECHAT_APPID` | ✅ | 微信公众号AppID |
  129. | `WECHAT_SECRET` | ✅ | 微信公众号AppSecret |
  130. | `ZHIPU_API_KEY` | ⚠️ | 智谱AI API Key(封面生成) |
  131. | `GOOGLE_API_KEY` | ❌ | Gemini API Key(可选) |
  132. ### 获取配置
  133. #### 微信公众号
  134. 1. 登录[公众号后台](https://mp.weixin.qq.com)
  135. 2. 开发 → 基本配置
  136. 3. 复制AppID和AppSecret
  137. #### 智谱AI
  138. 1. 访问[智谱AI开放平台](https://open.bigmodel.cn/)
  139. 2. 注册并创建API Key
  140. ## 🔧 故障排查
  141. ### IP不在白名单(40164)
  142. ```bash
  143. # 检查当前IP
  144. curl https://api.ipify.org
  145. # 添加到白名单
  146. 公众号后台 → 开发 → 基本配置 → IP白名单
  147. ```
  148. ### 无效media_id(40007)
  149. **原因**:使用了临时素材而非永久素材
  150. **解决**:确保使用 `/material/add_material` 接口
  151. ### 摘要超长(45004)
  152. **解决**:摘要限制在80字以内
  153. ```python
  154. digest = plain_text[:80] + '...'
  155. ```
  156. ### 排版内容为空
  157. **原因**:文章格式不支持
  158. **解决**:使用增强版排版工具
  159. ```python
  160. # ❌ 标准
  161. from scripts.wechat_typesetter import WeChatTypesetter
  162. # ✅ 增强版(支持小红书)
  163. from scripts.wechat_typesetter_enhanced import WeChatTypesetterEnhanced
  164. ```
  165. ## 📊 性能指标
  166. | 操作 | 平均耗时 |
  167. |------|---------|
  168. | 封面生成(智谱AI) | 10-20秒 |
  169. | 封面生成(本地) | 1-2秒 |
  170. | 封面上传 | 2-5秒 |
  171. | 排版 | 1秒 |
  172. | 创建草稿 | 2-3秒 |
  173. | **总耗时** | **15-30秒** |
  174. ## 🎓 最佳实践
  175. ### 封面生成
  176. ```python
  177. # 好的提示词
  178. prompt = "A tech cover for AI article, gradient blue background, robotic teamwork"
  179. # 避免模糊描述
  180. # ❌ prompt = "A cover"
  181. ```
  182. ### 排版选择
  183. ```python
  184. # 小红书格式
  185. if "🎯" in content or "✅" in content:
  186. typesetter = WeChatTypesetterEnhanced()
  187. # 标准Markdown
  188. else:
  189. typesetter = WeChatTypesetter()
  190. ```
  191. ### 发布流程
  192. ```python
  193. # 1. 先预览HTML
  194. html = typesetter.format(content)
  195. with open("preview.html", "w") as f:
  196. f.write(html)
  197. # 2. 检查摘要
  198. if len(digest) > 80:
  199. digest = digest[:80] + "..."
  200. # 3. 确认IP
  201. current_ip = get_current_ip()
  202. if current_ip != configured_ip:
  203. update_whitelist(current_ip)
  204. ```
  205. ## 🤝 贡献
  206. 欢迎提交Issue和Pull Request!
  207. ### 开发环境
  208. ```bash
  209. git clone https://github.com/your-username/wechat-publisher-pro.git
  210. cd wechat-publisher-pro
  211. pip install -r requirements.txt
  212. cp .env.example .env
  213. # 编辑.env
  214. ```
  215. ### 测试
  216. ```bash
  217. python -m pytest tests/
  218. ```
  219. ## 📄 许可证
  220. [MIT License](LICENSE)
  221. ## 🙏 致谢
  222. - [wechat-typesetting-cy](https://github.com/CY-CHENYUE/wechat-typesetting-cy) - 排版技能灵感
  223. - [智谱AI](https://open.bigmodel.cn/) - 封面生成API
  224. ## 📮 联系方式
  225. - Issue: [GitHub Issues](https://github.com/your-username/wechat-publisher-pro/issues)
  226. - Email: your-email@example.com
  227. ---
  228. **维护者**: AutoClaw 🦞
  229. **版本**: 1.0.0
  230. **最后更新**: 2026-03-26

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.