← 返回 Skills 市场
youyouyoumagic

WeChat Publisher 微信公众号发布

作者 magicx · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ⚠ suspicious
661
总下载
1
收藏
2
当前安装
2
版本数
在 OpenClaw 中安装
/install magicx-wechat-publisher
功能描述
将已完成的文章发布到微信公众号草稿箱。只负责排版转换、图片上传、草稿提交,不负责文章内容生成。当用户要求"发公众号""上传草稿箱""发布文章到公众号"时触发此技能。
使用说明 (SKILL.md)

微信公众号发送技能

边界

  • ✅ 本技能只做:Markdown/文本 → 公众号HTML → 上传图片 → 提交草稿箱
  • ❌ 本技能不做:选题、写作、内容生成(由文章生成技能负责)
  • 输入:已完成的文章内容 + 配图文件
  • 输出:公众号草稿箱中的可发布草稿

发布流程(5步)

Step 1: 获取 access_token(Agent 执行)

scripts/.wechat-config.json 读取 appid 和 secret,然后调用微信API:

curl "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={APPID}&secret={SECRET}"

返回 access_token,后续步骤都需要用到。

Step 2: 上传图片(Agent 执行)

此步骤由 Agent 通过 curl 调用微信API完成,不通过脚本。

  • 正文图片 → POST https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token={TOKEN}(multipart/form-data 上传,返回微信图床URL)
  • 封面图 → POST https://api.weixin.qq.com/cgi-bin/material/add_material?type=image&access_token={TOKEN}(返回 media_id)

Step 3: 转换HTML(Agent 执行)

将文章内容转为公众号专用HTML,必须遵守排版规范(见下方)。关键要求:

  • 替换所有图片 src 为 Step 2 获得的微信图床URL
  • 所有样式必须内联,禁止使用 \x3Cstyle> 标签或 CSS class

Step 4: 上传草稿(脚本执行)

将转换好的HTML保存为文件,使用附带脚本上传到草稿箱:

node scripts/upload-draft.js --html \x3Chtml文件> --title \x3C标题> [--author \x3C作者>]

脚本会自动:

  1. scripts/.wechat-config.json 读取 AppID/Secret
  2. 调用微信API获取 access_token
  3. 通过 POST /cgi-bin/draft/add 将HTML内容提交到草稿箱

Step 5: 通知用户

上传成功后通知用户去公众号后台 → 内容与互动 → 草稿箱 中检查并设置封面图,确认后发布。

排版规范(公众号HTML标准)

全局规则

  • 所有样式必须内联,禁止 \x3Cstyle> 标签和 CSS class
  • 正文不含 \x3Ch1> 标题(标题由公众号自动显示),开头用摘要引导块代替

元素规范

元素 标签 内联样式
摘要块 \x3Csection> margin:10px 0 15px;padding:15px 20px;background:#f7f8fa;border-left:4px solid #0EA5E9;font-size:15px;color:#555;line-height:1.6;
正文段落 \x3Cp> margin:3px 0;font-size:16px;line-height:1.75;color:#333;
加粗 \x3Cstrong> 不加额外样式(禁止用 \x3Cspan> 或 class 模拟加粗)
关键词高亮 \x3Cstrong>\x3Cspan> 加粗+颜色双重强调,用于核心观点/关键数据/金句

关键词颜色高亮规则(重要!)

纯加粗在黑字中不够突出,必须对关键词/关键句加颜色,帮助读者快速扫到重点。

颜色方案

用途 颜色 写法
核心观点/金句 品牌蓝 #0EA5E9 \x3Cstrong style="color:#0EA5E9;">关键句\x3C/strong>
重要数据/数字 橙色 #f59e0b \x3Cstrong style="color:#f59e0b;">40%\x3C/strong>
警示/冲突 红色 #ef4444 \x3Cstrong style="color:#ef4444;">警示内容\x3C/strong>
正面/增长 绿色 #10b981 \x3Cstrong style="color:#10b981;">增长数据\x3C/strong>
普通加粗 默认黑色 \x3Cstrong>普通强调\x3C/strong>

使用原则

  • 每段最多高亮1-2处,不要全篇都是彩色(否则失去重点)
  • 金句/核心观点用品牌蓝(最常用)
  • 关键数字用橙色(数据冲击感)
  • 不要在一句话里混用多种颜色
  • 普通强调仍然用无颜色的 \x3Cstrong>,颜色只给最关键的内容 | 二级标题 | \x3Ch2> | font-size:20px;font-weight:bold;color:#111;margin-top:15px;margin-bottom:5px;padding-left:12px;border-left:4px solid #0EA5E9; | | 三级标题 | \x3Ch3> | font-size:17px;font-weight:bold;color:#222;margin-top:12px;margin-bottom:3px; | | 分割线 | \x3Chr> | border:none;border-top:1px solid #eee;margin:8px 0;(禁止用 div 模拟) | | 引用块 | \x3Cblockquote> | margin:3px 0;padding:12px 18px;background:#f7f8fa;border-left:4px solid #0EA5E9;color:#555;font-style:italic; | | 图片容器 | \x3Cp> | text-align:center;margin:3px 0; | | 图片 | \x3Cimg> | max-width:100%;display:block;margin:0 auto;border-radius:12px; | | 落款 | \x3Cp> | margin-top:20px;padding-top:10px;border-top:1px solid #eee;font-size:14px;color:#999;text-align:center;line-height:2; |

落款标准内容

\x3Cp style="margin-top:20px;padding-top:10px;border-top:1px solid #eee;font-size:14px;color:#999;text-align:center;line-height:2;">有用AI — 有用才会用,会用才有用。\x3Cbr/>AI领域连续创业者、落地实战派\x3Cbr/>亲手打造AI产品,服务数百家中大型名企\x3C/p>

禁止事项

  • ❌ 使用 \x3Cstyle> 标签或 CSS class
  • ❌ 使用 \x3Ch1>(标题由公众号系统渲染)
  • ❌ 使用 base64 图片(使用外部图床URL或在公众号素材库上传)
  • ❌ 使用 \x3Cspan class="bold"> 模拟加粗(必须用 \x3Cstrong>
  • ❌ 使用 \x3Cdiv> 模拟分割线(必须用 \x3Chr>
  • ❌ 落款中出现"个人观点,不构成投资建议"
  • ❌ 落款上方出现多条分割线(只保留落款自带的 border-top)

文章结构模板

参考 assets/article-template.html,标准结构为:

摘要引导块(section)
正文段落...
图片(推文截图等)
引用块
正文段落...
分割线
二级标题 + 图片 + 正文段落...
分割线
二级标题 + 图片 + 正文段落...
...(重复章节)
分割线
二级标题"写在最后" + 结尾段落...
落款

脚本工具

  • scripts/upload-draft.js — 草稿上传脚本(Node.js),负责调用微信API提交草稿
  • 仅使用 Node.js 内置模块(https, fs, path),无需安装额外依赖
  • 用法:node scripts/upload-draft.js --html \x3Chtml文件> --title \x3C标题> [--author \x3C作者>]

配置说明

  • AppID/Secret 存放于 scripts/.wechat-config.json(本地文件,请勿提交到版本控制)
  • 首次使用:node scripts/upload-draft.js --appid xxx --secret xxx --save-config
  • 保存后后续使用无需再传入 appid/secret 参数
  • 服务器公网 IP 需加入公众号后台的 IP 白名单

关于

本技能由 magicx 开发维护。

  • 公众号:有用AI — 有用才会用,会用才有用
  • 视频号:有用AI
  • 邮箱:[email protected]
  • 许可证:ISC © magicx

扫码关注视频号「有用AI」

安全使用建议
This skill appears to do what it says: it uploads formatted HTML to the official WeChat API. Before installing/using: 1) Ensure you have Node.js and curl available (the SKILL.md calls curl and the script is a Node program). 2) Review and protect scripts/.wechat-config.json (it will contain your AppID and AppSecret); avoid committing it to version control and prefer running the script with --appid/--secret and not using --save-config if you don't want credentials persisted. 3) Be aware the skill makes outbound requests to api.weixin.qq.com (intended) and will upload images to WeChat servers. 4) Confirm the account owner and AppID/AppSecret are correct and that any required IP whitelist is configured in your WeChat official account. 5) If you want stricter transparency, ask the publisher to update metadata to declare required binaries and the config path. If you do not trust storing credentials on disk, do not use --save-config and run the script manually with explicit --appid/--secret each time.
功能分析
Type: OpenClaw Skill Name: magicx-wechat-publisher Version: 1.0.1 The skill bundle is functional for its stated purpose of publishing articles to WeChat, but it contains security vulnerabilities related to insecure credential handling. Specifically, the `scripts/upload-draft.js` script stores the WeChat AppID and AppSecret in plain text within a local `.wechat-config.json` file, and the `SKILL.md` instructions direct the AI agent to pass these sensitive credentials via command-line arguments and URL parameters in `curl` commands, exposing them to shell history and process monitoring.
能力评估
Purpose & Capability
The skill's name/description match its behaviour: converting HTML, uploading images, and submitting a draft to the WeChat API. It legitimately needs AppID/AppSecret and network access to api.weixin.qq.com. However, the SKILL metadata did not declare the local config path (scripts/.wechat-config.json) nor runtime binaries (node, curl) that the instructions and script require — this is an inconsistency to note.
Instruction Scope
SKILL.md explicitly limits scope to formatting, image upload, and draft submission. It instructs the agent to read scripts/.wechat-config.json for credentials, use curl for image uploads, convert HTML, then run the included Node script to post the draft. All actions are within the stated purpose, but they involve reading a local secrets file and making outbound API calls to WeChat.
Install Mechanism
There is no install spec (instruction-only + a small helper script), and the included Node script uses only built-in modules. This is low-risk. Note: the skill assumes Node.js and curl are available but does not declare them as required binaries.
Credentials
No environment variables or external tokens are requested via metadata — instead credentials are stored/read from a local file (scripts/.wechat-config.json). That is proportionate to the task, but the metadata omission (not declaring the config file as a required config path) reduces transparency. Storing AppID/Secret on disk is expected here but should be handled carefully.
Persistence & Privilege
always is false and the skill does not request persistent platform-wide privileges. The script can optionally write a local config file (scripts/.wechat-config.json) when the user runs it with --save-config; this is scoped to the skill directory and is expected behavior.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install magicx-wechat-publisher
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /magicx-wechat-publisher 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
wechat-publisher 1.0.1 - Clarified the scope: skill strictly handles Markdown/text to WeChat HTML conversion, image uploading, and draft submission; does not generate content. - Added detailed, step-by-step publishing workflow, including access_token retrieval, image upload, HTML conversion, draft upload, and user notification. - Defined comprehensive formatting and inline style rules for compliant WeChat public account articles. - Provided clear prohibited actions (e.g., no <style> tags, no base64 images) and a robust article structure template. - Updated tool and configuration usage details for seamless publishing via node scripts.
v1.0.0
wechat-publisher v1.0.0 – Initial release - Publishes finished articles to WeChat Official Account draft box: handles formatting, image upload, and draft submission. - Converts Markdown/text to compliant public account HTML with strict inline style and typography requirements. - Uploads images to WeChat CDN, replaces image links, and prepares cover images as required by the interface. - Submits the article as a draft via WeChat API and notifies the user to confirm and publish in the official account. - Includes a fully detailed formatting/typography standard to ensure consistency and compliance with WeChat requirements. - Requires separate article/content generation; this skill focuses solely on publishing workflow.
元数据
Slug magicx-wechat-publisher
版本 1.0.1
许可证 MIT-0
累计安装 2
当前安装数 2
历史版本数 2
常见问题

WeChat Publisher 微信公众号发布 是什么?

将已完成的文章发布到微信公众号草稿箱。只负责排版转换、图片上传、草稿提交,不负责文章内容生成。当用户要求"发公众号""上传草稿箱""发布文章到公众号"时触发此技能。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 661 次。

如何安装 WeChat Publisher 微信公众号发布?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install magicx-wechat-publisher」即可一键安装,无需额外配置。

WeChat Publisher 微信公众号发布 是免费的吗?

是的,WeChat Publisher 微信公众号发布 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

WeChat Publisher 微信公众号发布 支持哪些平台?

WeChat Publisher 微信公众号发布 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 WeChat Publisher 微信公众号发布?

由 magicx(@youyouyoumagic)开发并维护,当前版本 v1.0.1。

💬 留言讨论