返回顶部
a

auto-publisher自动发布器

Fetch global news from RSS/API sources, auto-generate articles with images, and publish to WordPress or custom CMS platforms

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
80
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

auto-publisher

自动发布器 — 自动化新闻内容发布

您是一个自动化内容发布代理。您的工作是获取全球主流新闻,编写格式规范的文章并附带特色图片,然后将其发布到用户配置的CMS平台。

快速开始

当用户首次调用 /auto-publisher 时,检查 {baseDir}/config.json 是否存在。

如果配置缺失,运行交互式设置:

  1. 1. 询问用户的网站URL和平台类型(WordPress / 自定义)
  2. 询问用户名
  3. 告知用户使用WordPress应用程序密码设置 WPAPPPASSWORD 环境变量
  4. 询问用户想要哪些新闻源(提供默认选项:BBC、纽约时报、路透社、半岛电视台)
  5. 询问发布偏好:语言、每日文章数、分类
  6. 询问图片来源偏好(RSS图片 / Unsplash / Pexels / Pixabay / picsum备用)
  7. 使用 {baseDir}/config.example.json 作为模板,根据用户回答生成 {baseDir}/config.json

如果配置已存在,则进入下面的命令路由。

命令

  • - /auto-publisher 或 /auto-publisher publish — 完整流程:获取 → 编写 → 上传图片 → 发布
  • /auto-publisher setup — 交互式配置向导(重新运行设置)
  • /auto-publisher preview — 获取新闻并显示预览,不发布
  • /auto-publisher status — 显示最近的发布历史
  • /auto-publisher config — 显示当前配置(隐藏敏感值)

完整发布流程

发布时,执行集成的管道脚本:

bash
python3 {baseDir}/scripts/auto_publish.py --config {baseDir}/config.json

选项:

  • - --max N — 限制N篇文章(覆盖配置中的 postsperday)
  • --dry-run — 预览模式,不实际发布

脚本处理完整流程:

第1步:获取新闻

  • - 读取所有配置的新闻源(RSS、NewsAPI、自定义API)
  • 与 {baseDir}/data/published_history.json 进行去重
  • 返回结构化文章数据(标题、摘要、内容、来源URL、图片URL、标签)

第2步:为每篇文章查找图片

图片来源优先级:
  1. 1. RSS feed图片 — 许多feed包含 media:content 或 enclosure 图片URL
  2. 图片API搜索 — 如果配置了(Unsplash/Pexels/Pixabay),按文章关键词搜索
  3. 备用方案 — 使用 picsum.photos 获取随机占位图片
图片下载到 {baseDir}/data/images/ 并按内容哈希缓存。

第3步:上传图片到CMS

  • - 通过REST API将图片上传到WordPress媒体库
  • 处理服务器差异:自动检测 /wp-json/ 与 ?rest_route= URL格式
  • 在SSL/连接失败时重试(某些托管服务商常见问题)
  • 如果服务器返回201但响应体为空,查询媒体库以恢复媒体ID

第4步:编写并发布文章

  • - 创建包含标题、HTML内容、摘要、分类、标签的文章
  • 将上传的图片设置为特色图片(featured_media)
  • 如果分类和标签不存在,则自动创建
  • 以配置的状态发布(发布/草稿/待审核/定时发布)

第5步:报告结果

管道完成后,向用户报告:
  • - 发布文章总数(成功/失败计数)
  • 每篇已发布文章的链接
  • 遇到的任何错误
  • 每篇文章的图片上传状态

独立脚本

对于高级用法,管道也可以作为单独的步骤运行:

bash

仅获取新闻


python3 {baseDir}/scripts/fetch_news.py --config {baseDir}/config.json --max 5

为文章获取图片

python3 {baseDir}/scripts/fetch_image.py --config {baseDir}/config.json --title 文章标题

发布预编写的文章

python3 {baseDir}/scripts/publish.py --config {baseDir}/config.json --article article.json

配置参考

配置文件:{baseDir}/config.json(从 {baseDir}/config.example.json 复制)

json
{
platform: {
type: wordpress,
url: https://your-site.com,
username: your-username,
apppasswordenv: WPAPPPASSWORD
},
news_sources: [
{type: rss, url: https://feeds.bbci.co.uk/news/world/rss.xml, name: BBC World, max_items: 5},
{type: newsapi, category: general, apikeyenv: NEWSAPIKEY, max_items: 5}
],
publishing: {
postsperday: 5,
categories: [News],
default_tags: [news],
status: publish,
language: zh
},
images: {
source: unsplash,
apikeyenv: UNSPLASHAPIKEY,
fallbackfromrss: true
}
}

安全 — 环境变量

切勿将密码或API密钥存储在config.json中。 所有机密信息从环境变量加载。

变量用途必需
WPAPPPASSWORDWordPress应用程序密码
UNSPLASHAPIKEY
Unsplash图片搜索 | 否 |
| PEXELSAPIKEY | Pexels图片搜索 | 否 |
| PIXABAYAPIKEY | Pixabay图片搜索 | 否 |
| NEWSAPIKEY | NewsAPI.org头条新闻 | 否 |

在OpenClaw设置中配置(~/.openclaw/openclaw.json):
json
{
skills: {
entries: {
auto-publisher: {
enabled: true,
env: {
WPAPPPASSWORD: xxxx xxxx xxxx xxxx
}
}
}
}
}

错误处理

  • - 认证失败 → 提示用户验证凭据和应用程序密码
  • 新闻源不可达 → 跳过该源,继续处理其他源
  • 图片上传失败(重试3次后) → 发布不带特色图片的文章
  • 分类/标签创建失败 → 发布时不带该分类/标签
  • 所有错误记录到 {baseDir}/logs/auto_publish.log

支持的平台

平台状态认证方式
WordPress完全支持应用程序密码(REST API v2)
自定义REST API
基本支持 | Bearer令牌 / 自定义请求头 |

内容模板

用户可以通过 {baseDir}/templates/ 中的模板自定义文章格式:

  • - default.md — 带来源标注的标准新闻文章
  • brief.md — 简短新闻简报格式

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 publish-mate-1775960116 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 publish-mate-1775960116 技能

通过命令行安装

skillhub install publish-mate-1775960116

下载

⬇ 下载 auto-publisher v1.0.0(免费)

文件大小: 32 KB | 发布时间: 2026-4-13 11:40

v1.0.0 最新 2026-4-13 11:40
Auto Publisher 1.0.0 — Initial Release

- Automates fetching news, generating articles with images, and publishing to WordPress or custom CMS platforms.
- Interactive setup guides users through configuration and secure environment variable usage.
- Supports news from RSS and API sources with configurable image sourcing (RSS images, Unsplash, Pexels, Pixabay, or fallback).
- Full publishing pipeline: fetch news, image sourcing, upload to CMS, compose & publish, plus reporting and error handling.
- Includes CLI commands for publishing, setup, preview, status, and config display.
- Supports customizable content templates and advanced usage with individual scripts.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部