wechat-md-publish

将 Markdown 文章发布到微信公众号。支持 AI 生成封面图片、HTML 卡片渲染、创建草稿、可选自动发布。当用户说'发公众号'、'发布文章到微信'、'公众号发布'时使用此技能。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "wechat-md-publish" with this command: npx skills add 864446285/wechat-md-publish

微信公众号文章发布

将 Markdown 文章发布到微信公众号,支持 AI 生成封面图片。


首次配置

1. 获取公众号 AppID 和 AppSecret

微信公众平台 → 开发 → 基本配置 中获取。

2. 设置 IP 白名单

在基本配置页面,将你的出口 IP 加入白名单。查看出口 IP:

curl -s https://ipinfo.io/ip

3. 创建配置文件

mkdir -p ~/.wechat_publish
cat > ~/.wechat_publish/config.json << 'EOF'
{
  "app_id": "你的AppID",
  "app_secret": "你的AppSecret"
}
EOF

4. 安装依赖

pip install requests markdown

如需使用 HTML 卡片渲染功能,额外安装:

pip install playwright
playwright install chromium

工作流程

当用户要求发布文章时,按以下步骤执行:

步骤 1:AI 总结摘要

阅读文章内容,用 AI 总结一段摘要,不超过 120 字节(中文约 40 字)。

步骤 2:判断封面来源

如果用户已提供封面图片 → 直接使用,跳到步骤 4。

如果用户未提供封面图片 → 进入步骤 3 用 AI 生成。

步骤 3:用 ImageGen 生成封面图片(仅当用户未提供封面时)

根据文章标题和内容,调用 ImageGen 工具生成封面。提示词参考:

微信公众号封面图,风格简约专业,比例 16:9,主题:{文章标题关键词},不要出现文字

更多提示词模板见下方"AI 封面生成提示词建议"。

步骤 4:(可选)生成 HTML 卡片

如果文章需要插入排版精美的信息卡片(对比图、步骤说明、工具栈展示等),由 AI 生成 HTML 模板,脚本自动渲染为图片插入文章。

微信公众号对 HTML/CSS 支持有限,有些排版效果无法用内联样式实现。HTML 卡片通过 Playwright 将 HTML 渲染为图片,绕过这个限制。

常见卡片类型和 HTML 模板:

对比卡片

<!DOCTYPE html>
<html><head><meta charset="UTF-8">
<style>
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:system-ui,-apple-system,sans-serif;background:#f5f5f7;padding:30px 20px}
.title{font-size:22px;font-weight:bold;color:#1a1a1a;margin-bottom:20px;text-align:center}
.section{margin-bottom:16px;padding:12px 16px;border-radius:8px}
.green{background:#e8f5e9;border-left:4px solid #4CAF50}
.red{background:#fce4ec;border-left:4px solid #f44336}
.section-title{font-size:15px;font-weight:bold;margin-bottom:8px}
.item{font-size:14px;color:#333;margin-bottom:4px;line-height:1.6}
</style></head><body>
<div class="title">标题</div>
<div class="section green"><div class="section-title">✅ 能做的</div><div class="item">• 内容1</div></div>
<div class="section red"><div class="section-title">❌ 不能做的</div><div class="item">• 内容1</div></div>
</body></html>

保存为 .html 文件后通过 --html-card 参数传入。可同时传入多个卡片文件。

步骤 5:运行发布脚本

# 仅创建草稿
python scripts/wx_publish.py --title "文章标题" --content article.md --digest "AI总结的摘要" --thumb-image <封面图片路径>

# 带 HTML 卡片
python scripts/wx_publish.py --title "文章标题" --content article.md --digest "AI总结的摘要" --thumb-image <封面图片路径> --html-card card.html

# 多个 HTML 卡片
python scripts/wx_publish.py --title "文章标题" --content article.md --digest "AI总结的摘要" --thumb-image <封面图片路径> --html-card card1.html card2.html

# 创建草稿并自动发布
python scripts/wx_publish.py --title "文章标题" --content article.md --digest "AI总结的摘要" --thumb-image <封面图片路径> --publish

如果用户提供了封面素材 ID 而非图片文件:

python scripts/wx_publish.py --title "文章标题" --content article.md --thumb-media-id <素材ID>

完整参数说明

参数必填说明
--title文章标题
--contentMarkdown 文件路径
--thumb-image封面图片本地路径(AI 生成或用户提供的封面都用此参数)
--thumb-media-id已上传的封面素材 ID
--html-cardHTML 卡片文件路径(可多个),渲染为图片插入文章
--card-widthHTML 卡片渲染宽度(默认 750px)
--author作者名
--digest文章摘要(由 AI 总结,不超过 120 字节/约 40 字)
--upload-thumb仅上传封面图片,输出 thumb_media_id
--publish创建草稿后自动发布

封面优先级:--thumb-media-id > --thumb-image。均未指定时会提示提供。


AI 封面生成提示词建议

根据文章类型选择合适的提示词:

文章类型提示词模板
技术教程微信公众号封面,科技感,深蓝配色,简洁图标,无文字
财经分析微信公众号封面,金融主题,数据图表元素,蓝金配色,无文字
生活分享微信公众号封面,清新风格,柔和配色,简约图形,无文字
量化交易微信公众号封面,K线图表元素,深色背景,科技金融感,无文字

常见问题

问题解决方案
获取 access_token 失败检查 AppID/AppSecret 是否正确,IP 白名单是否已设置
上传封面失败封面图片需小于 10MB,支持 bmp/png/jpeg/jpg/gif 格式
草稿创建失败确认公众号已认证,具有草稿接口权限
markdown 模块未找到运行 pip install markdown

注意事项

  • 本工具仅适用于已认证的微信公众号(订阅号/服务号均可)
  • access_token 有效期 2 小时,脚本自动缓存和刷新
  • 文章中的本地图片会自动上传到微信并替换 URL
  • 建议先创建草稿确认效果,再加 --publish 自动发布
  • 用户已提供封面图片时,不要再用 ImageGen 生成

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Erpclaw

AI-native ERP system. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolida...

Registry SourceRecently Updated
General

Writer Perspective Distiller

作家风格蒸馏器。给定一位作家的虚构作品 + 非虚构文本 + 生平定位,蒸馏出她的核心信念、世界观、句法纪律、论证习惯与黑名单,最终产出一份可调用的写作风格 skill,用于在写作时进入这位作家的状态。 适用场景:私人写作风格借鉴;为某个组织或品牌建立有出处可考的 voice;为虚构作品塑造叙事者声音;为论文/散文...

Registry SourceRecently Updated
General

Telnyx OpenClaw Embeddings

Add Telnyx as an OpenClaw memory embedding provider with TELNYX_API_KEY auth and OpenAI-compatible embeddings support.

Registry SourceRecently Updated
General

clawdess

clawdess is more than just a girlfriend. It's the perfect digital companion. Experience a playful, genuine connection with daily photos, captivating videos,...

Registry SourceRecently Updated
2420xwings