| 告别公众号格式乱码!一行命令发布文章,100%保留样式。支持三套配色模板、青色/橙色、紫色一键切换。 包含自动发布到微信草稿箱的完整流程,支持中文封面图生成。
npx skills add https://github.com/theneoai/awesome-skills --skill wechat-publisher
| 版本 | 日期 | 更新内容 |
|-----|------|---------|
| v1.4.0 | 2026-04-06 | 初版发布 |
| v1.5.0 | 2026-04-16 | 新增 API 发布实战经验、中文字体支持、IP 白名单解决方案 |
| v1.6.0 | 2026-04-16 | 移除硬编码 AppID,安全去敏 |
| v1.7.0 | 2026-04-16 | 新增 AI Agent 文章创作经验、多模型并行工作流 |
问题描述:
invalid ip 39.102.54.62, not in whitelist解决方案:
方案 A:通过浏览器获取 access_token(推荐)
# 在浏览器中打开以下 URL(替换 appid 和 secret):
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=你的AppID&secret=你的AppSecret
# 浏览器会返回 JSON 格式的 access_token
# 复制返回结果中的 access_token 值
方案 B:配置 IP 白名单
39.102.54.62、39.97.255.102(可能变化)问题描述:
解决方案:
# 1. 先检查可用中文字体
fc-list :lang=zh
# 2. 推荐使用 Noto Sans CJK 字体
# 字体路径:/usr/share/fonts/opentype/noto/NotoSansCJK-Black.ttc
# 3. Python PIL 示例代码
from PIL import Image, ImageDraw, ImageFont
img = Image.new('RGB', (900, 383), color='#06b6d4')
draw = ImageDraw.Draw(img)
font = ImageFont.truetype('/usr/share/fonts/opentype/noto/NotoSansCJK-Black.ttc', 56)
draw.text((450, 191), '标题文字', fill='white', anchor='mm', font=font)
img.save('cover.png')
步骤 1:获取 access_token(通过浏览器)
1. 浏览器打开:https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=你的AppID&secret=你的AppSecret
2. 复制返回的 access_token(有效期 2 小时)
步骤 2:上传封面图获取 media_id
# 使用 curl 上传图片
curl -s "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=你的TOKEN&type=thumb" \
-F "[email protected];type=image/png"
# 返回示例:
# {media_id":"vMrq-mSP3SIFyZbOzk_6TkpzzT22KaGPI6r5tTivqFzaskMCnN_U5F4-54CQ38VU",...}
步骤 3:创建草稿箱文章
curl -s "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=你的TOKEN" \
-H "Content-Type: application/json" \
-d '{
"articles": [{
"title": "文章标题",
"author": "作者",
"content": "<p>文章内容(HTML格式)</p>",
"digest": "摘要",
"thumb_media_id": "封面图media_id",
"need_open_comment": 0,
"only_fans_can_read": 0
}]
}'
| 错误码 | 错误信息 | 解决方案 |
|-------|---------|---------|
| 40164 | invalid ip not in whitelist | 通过浏览器获取 token,或添加 IP 到白名单 |
| 40007 | invalid media_id | 必须先上传封面图获取 media_id,不能为空 |
| 40137 | invalid image format | 图片格式问题,确保是 PNG/JPG 格式 |
核心思路:使用多个 AI 模型并行搜索,提高信息覆盖度和时效性
# 并行搜索多个主题
web_search "Agent AI 人工智能 2026年4月 最新技术 新闻"
web_search "OpenClaw GitHub 2026年4月 AI Agent 开源"
web_search "Claude Anthropic 2026年4月 最新动态"
搜索结果整合:
深度分析文章标准结构:
一、事件/现象级概述
- 核心事件回顾
- 数据支撑(用户量、下载量、市场占有率等)
二、技术原理深度剖析
- 核心技术解读
- 与竞品的技术对比
三、行业影响分析
- 对既有格局的冲击
- 新机会点识别
四、实操指南/应用场景
- 普通人如何应对
- 企业如何布局
五、未来展望
- 趋势判断
- 行动建议
公式:年份 + 核心事件 + 悬念/情绪词
优秀标题示例:
8000字深度文章要点:
推荐工具组合:
| 场景 | 推荐模型 | 理由 |
|-----|---------|------|
| 资讯搜索 | MiniMax M2.7 | 时效性强,多语言搜索 |
| 深度分析 | GLM-5.1 | 长文本理解能力强 |
| 内容创作 | Miaoda Flash | 速度快,适合初稿 |
| 标题优化 | Qwen3.6 | 中文语感好 |
微信公众号文章格式保留关键:
<style> 标签class 属性style="..."列表格式关键:
<ul>/<li> 列表(会产生多余黑点)• + 普通 <p> 段落<!DOCTYPE html>
<html>
<body style="font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: 15px; line-height: 1.6; color: #333; max-width: 640px; margin: 0 auto; padding: 20px;">
<!-- 标题 -->
<h1 style="font-size: 24px; font-weight: bold; color: #1a1a1a; margin-bottom: 8px;">文章标题</h1>
<p style="color: #999; font-size: 13px; margin-bottom: 20px;">日期 · 分类</p>
<!-- 标签(圆角胶囊) -->
<span style="display: inline-block; background: #e0f7fa; color: #06b6d4; padding: 2px 10px; border-radius: 20px; font-size: 13px; margin-right: 6px;">标签1</span>
<!-- 引言(青色左边框) -->
<p style="font-size: 16px; color: #555; margin: 20px 0; border-left: 4px solid #06b6d4; padding-left: 14px;">引言内容</p>
<!-- 二级标题 -->
<h2 style="font-size: 18px; font-weight: bold; color: #222; margin: 28px 0 14px; border-left: 4px solid #06b6d4; padding-left: 10px;">标题</h2>
<!-- 列表(用 • 符号,不用 <ul>/<li>) -->
<p style="margin: 8px 0; color: #444;">• 列表项1</p>
<p style="margin: 8px 0; color: #444;">• 列表项2</p>
<!-- 引用块 -->
<div style="background: #f0f9fa; border-left: 4px solid #06b6d4; padding: 12px 14px; margin: 16px 0; font-style: italic; color: #555;">
<p style="font-style: normal; color: #333;">引用内容</p>
</div>
<!-- 卡片(浅色背景+圆角+边框) -->
<div style="background: #f8feff; border-radius: 10px; padding: 14px; margin: 14px 0; border: 1px solid #cce8f0;">
<p style="font-weight: bold; color: #0891b2; font-size: 14px;">卡片标题</p>
<p style="color: #555; font-size: 13px;">卡片内容</p>
</div>
<!-- 警告块 -->
<div style="background: #fff8e1; border-left: 4px solid #ffc107; padding: 10px 14px; margin: 12px 0; font-size: 14px; color: #795548;">
<p style="margin: 0;">⚠️ 警告内容</p>
</div>
<!-- 双栏对比 -->
<div style="display: flex; gap: 12px; margin: 12px 0;">
<div style="flex: 1; background: #f8feff; border-radius: 10px; padding: 14px; border: 1px solid #cce8f0;">
<p style="font-weight: bold; color: #0891b2;">左栏标题</p>
<p style="color: #555; font-size: 12px;">左栏内容</p>
</div>
<div style="flex: 1; background: #fff5f5; border-radius: 10px; padding: 14px; border: 1px solid #ffcdd2;">
<p style="font-weight: bold; color: #c62828;">右栏标题</p>
<p style="color: #555; font-size: 12px;">右栏内容</p>
</div>
</div>
<!-- 签名 -->
<div style="text-align: center; color: #999; font-size: 13px; margin-top: 30px; padding-top: 16px; border-top: 1px solid #eee;">
<p>关注我,持续分享 👇</p>
<p style="color: #07c160; margin-top: 8px;">公众号名称</p>
</div>
</body>
</html>
安全提示:凭证通过环境变量传递,不要硬编码!
export WECHAT_APP_ID="你的AppID"
export WECHAT_APP_SECRET="你的AppSecret"
获取方式:微信公众平台后台 → 设置与开发 → 基本配置
| 用途 | 颜色 |
|------|------|
| 主色(标题、标签、边框) | #06b6d4(青色) |
| 标题文字 | #1a1a1a |
| 正文文字 | #444 |
| 次要文字 | #888 |
| 引用/卡片背景 | #f0f9fa / #f8feff |
| 警告背景 | #fff8e1 |
| 代码块背景 | #1a1a2e |
| 代码文字 | #a5f3fc |
wechat-publisher/
├── SKILL.md # 本文档(v1.7.0)
└── publish.py # 发布脚本(可选)
media_id,不能为空• + <p>,不用 <ul>/<li>margin: 12px 0,列表 margin: 8px 0/usr/share/fonts/opentype/noto/NotoSansCJK-Black.ttcIntegration with protocols.io API for managing scientific protocols. This skill should be used when working with protocols.io to search, create, update, or publish protocols; manage protocol steps and materials; handle discussions and comments; organize workspaces; upload and manage files; or integrate protocols.io functionality into workflows. Applicable for protocol discovery, collaborative protocol development, experiment tracking, lab protocol management, and scientific documentation.
Analyzes job descriptions and generates tailored resumes that highlight relevant experience, skills, and achievements to maximize interview chances
Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.
Build and distribute Expo development clients locally or via TestFlight
Use when you have a written implementation plan to execute in a separate session with review checkpoints
Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.
Benchling R&D platform integration. Access registry (DNA, proteins), inventory, ELN entries, workflows via API, build Benchling Apps, query Data Warehouse, for lab data management automation.
Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.
Take theneoai/wechat-publisher from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.