Skip to content
Projetos

jiji262/wechat-publisher

Ver no GitHub

Sobre

微信公众号文章自动创作与发布工具 - WeChat Official Account article auto-creation and publishing tool

Design e mídia

Como estes números são medidos

Crescimento medido de estrelas

em 24 h
0
em 7 dias
+4
em 15 dias
+4
em 1 mês
Coletando histórico

Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.

README.md

Original

wechat-publisher

微信公众号文章自动创作与发布工具:从选题搜索、撰写、AI 配图、排版到发布草稿箱,一条命令搞定。可作为 Claude Code / Codex / Cursor 的 Skill,也可独立命令行调用。

功能

  • 全网素材搜索:围绕话题多轮搜索、交叉验证,筛选最新案例与权威观点
  • AI 写作:材料决定篇幅;writing_context.py 将当前材料、结构库说明、结构规划、技术文章的内容要求、本人样本和用户改稿反馈交给独立写作 pass。没有本人样本时明确采用账号编辑风格
  • 技术文章结构:先定读者任务(弄懂机制 / 复现操作 / 做选型 / 判断事件),再按理解依赖分节;每节推进一条论断,观点带条件,图只表达关系
  • 标题编辑检查:生成 5 个角度不同的候选,用 title_check.py 查长度、具体对象、模板词、否定对照和夸张动词
  • AI 配图:初稿在需要的地方写图位,按图位配图(scripts/generate_image.py 手绘信息图,或排版卡),一篇内风格统一,支持 OpenAI / Gemini 后端
  • 微信排版:Markdown → 微信兼容 HTML,样式全内联,内置 15 套主题,粘贴不丢样式
  • 一键发布:封面、标题、摘要、作者自动填好,直达草稿箱
  • 去 AI 味改稿流程:初稿快照 → 结构层检查(标题、小标题、开篇、结尾、段落形状) → ai_score.py 负向模式 lint(带行号的 advisory 清单)→ 按语境编辑(允许段落重组) → 全新上下文冷读 → fidelity_check.py 保真核对 + fingerprint.py 跨篇比对
  • 发布预检:风格分数、普通 advisory 与格式提示只供编辑参考,不阻断发布;同形字和未核对出处的亲历/引语仍拒发,零宽字符自动清除。句长、标点不计入总分;低分不证明自然,也不证明像本人

安装

作为 Skill 安装(通过 skills.sh):

npx skills add jiji262/wechat-publisher

或手动安装到 Agent 客户端(推荐软链接,更新仓库即自动生效):

git clone https://github.com/jiji262/wechat-publisher.git
cd wechat-publisher
pip install requests pyyaml

# Claude Code / Codex / OpenClaw 任选其一:
ln -s "$(pwd)" ~/.claude/skills/wechat-publisher
ln -s "$(pwd)" ~/.codex/skills/wechat-publisher
ln -s "$(pwd)" ~/.openclaw/skills/wechat-publisher

安装后重启客户端或新开会话让 skill 被发现。

配置

复制模板并填入凭证:

cp wechat-publisher.yaml.example wechat-publisher.yaml
default: main
accounts:
  main:
    name: "我的公众号"
    app_id: "wx..."
    app_secret: "..."
    author: "作者名"

image_generation:
  generator: "baoyu-image-gen"      # 或 baoyu-danger-gemini-web(Web 登录版 Gemini)
  gemini_proxy:
    base_url: "https://generativelanguage.googleapis.com"
    api_key: "AIza..."
    image_model: "gemini-2.5-flash"

integrations:
  wechatsync_mcp_token: ""

# 可选:发布内容和生图 prompt 里不许出现的词(大小写不敏感),命中即拒发
forbidden_terms: []

在微信公众平台 → 设置与开发 → 基本配置 获取 AppID / AppSecret,并把 curl ifconfig.me 得到的公网 IP 加入「IP 白名单」(否则报 40164)。验证连接:

python3 scripts/wechat_api.py list-accounts

使用

作为 Skill

使用 /wechat-publisher 写一篇关于"大模型 Agent 最新进展"的公众号文章

Skill 自动执行 7 阶段:搜索素材 → 按材料定结构 → 独立上下文撰写 → 定标题 → 改稿 pass(lint + 冷读 + 保真核对)→ 生成配图 → 排版转换 → AI 味 gate → 发布草稿 →(可选)多平台同步。完整流程见 SKILL.md。

命令行

# 一键发布:Markdown → 草稿箱
python3 scripts/publish.py --account main --input article.md \
  --cover cover.jpg --title "标题" --digest "摘要"

# 只转排版:Markdown → 微信 HTML
python3 scripts/html_converter.py article.md --theme refined-blue -o article.html

# 单独跑 AI 味检测(--advisory 列出带行号的 artifacts 与 advisory 清单)
python3 scripts/ai_score.py article.md --threshold 45
python3 scripts/ai_score.py article.md --advisory --brief brief.md --account main

# 标题候选检查(只提示,不阻断发布)
python3 scripts/title_check.py "候选标题 1" "候选标题 2"

# 发布到今日头条(首次需扫码一次,之后无人值守)
python3 scripts/publish.py --input article.md --platform toutiao
python3 scripts/publish.py --input article.md --platform wechat,toutiao

publish.py 会从 wechat-publisher.yaml 读 author / theme,依次做发布预检(风格仅提示;配置里的禁用词、同形字、中文里残留的半角标点与出处缺口阻断,禁用词不受 --skip-ai-score 影响)→ 本地缺图检查(引用的本地图片不存在就在上传前中止)→ 图片处理 → HTML 转换 → 封面上传 → 创建草稿。每个脚本 --help 查看完整参数。

排版主题

内置 15 套主题(assets/themes/*.json):正文 ~15.5px、行高 ~1.85、纯 inline style、无外部依赖。打开 assets/theme-previews/index.html 可在手机宽度 frame 里并排对比、按分类筛选。

15 套公众号主题总览

refined-blue preview
refined-blue · main 默认,AI / 产品 / 深度分析
minimal-mono preview
minimal-mono · tech 默认,技术 / 工程
news-bold preview
news-bold · 新闻 / 热点 / 速读
ink-wash preview
ink-wash · 人文 / 随笔 / 文化
类别 推荐主题
AI / 产品 / 深度分析 refined-blue(main 默认)· business-navy · sage-premium
技术 / SDK / 工程 minimal-mono(tech 默认)· minimal-bw · academic-paper
新闻 / 热点 / 速读 news-bold · warm-editorial
人文 / 随笔 / 文化 ink-wash · elegant-ink · magazine-grid
生活 / 美食 / 旅行 warm-orange · mint-fresh · sunset-coral
时尚 / 美妆 / 情感 girly-pink · sunset-coral

新增主题:复制任意 assets/themes/*.json 改名改键即可,无需改代码。详见 assets/theme-previews/README.md。

常见问题

错误 解决
ConfigError: 未找到 wechat-publisher.yaml 复制 .example 并填值
40164 IP 不在白名单 curl ifconfig.me 取 IP,加入公众平台白名单
40001 access_token 无效 检查 AppID / AppSecret
40009 图片超 10MB 压缩后重试
45166 内容不合规 检查敏感词或特殊 HTML 标签
ai_score.py 返回 FAIL 离线分数超阈值不等于不能发布;按语境编辑。同形字须清理,亲历/引语须核对来源
humanize_log 覆盖检查失败 发布只强制核对出处类条目;普通风格记录可选。亲历/引语无来源就删,或补可核对的保留行(写法见 references/anti-ai-checklist.md D 层)

注意事项

  • 文章发布到草稿箱,不会自动群发
  • access_token 有效期 2 小时,脚本自动缓存与刷新
  • 正文图走 uploadimg(不占素材名额),封面走 add_material(占用永久素材名额)

测试

pip install pytest
python3 -m pytest tests/ -v

测试不依赖真实微信凭证(网络调用全部 mock),覆盖配置解析、AI 味打分与 HTML 转换安全性。

License

MIT

Explore projetos relacionados

Carregando…