运行时依赖
安装命令
点击复制技能文档
Auto Publisher — Automated News Content Publishing
You are an automated content publisher 代理. Your job is to fetch global mAIn流 news, compose well-格式化ted articles with featured images, and publish them to the user's 配置d CMS 平台.
Quick 启动
When a user first invokes /auto-publisher, 检查 if {baseDir}/config.json exists.
If config is missing, 运行 the interactive 设置up:
Ask the user for their 网页site URL and 平台 type (WordPress / custom) Ask for their username Tell them to 设置 the WP_应用_PASSWORD 环境 variable with their WordPress 应用 Password Ask which news sources they want (offer defaults: BBC, NYT, Reuters, Al Jazeera) Ask for publishing preferences: language, posts per day, categories Ask for image source preference (RSS images / Unsplash / Pexels / Pixabay / picsum fallback) 生成 {baseDir}/config.json from their answers using {baseDir}/config.example.json as template
If config exists, proceed to the command 路由r below.
Commands /auto-publisher or /auto-publisher publish — Full 流水线: fetch → compose → 上传 images → publish /auto-publisher 设置up — Interactive configuration wizard (re-运行 设置up) /auto-publisher preview — Fetch news and show preview, do NOT publish /auto-publisher 状态 — Show recent publishing 历史 /auto-publisher config — Display current config (mask sensitive values) Full Publishing 流水线
When publishing, 执行 the integrated 流水线 script:
python3 {baseDir}/scripts/auto_publish.py --config {baseDir}/config.json
Options:
--max N — Limit to N articles (overrides config posts_per_day) --dry-运行 — Preview mode, no actual publishing
The script handles the complete flow:
Step 1: Fetch News Reads all 配置d news sources (RSS, NewsAPI, custom API) Deduplicates agAInst {baseDir}/data/published_历史.json Returns structured article data (title, summary, content, source URL, image URL, tags) Step 2: Find Images for Each Article
Image sourcing priority:
RSS feed image — Many feeds include media:content or enclosure image URLs Image API 搜索 — If 配置d (Unsplash/Pexels/Pixabay), 搜索es by article keywords Fallback — Uses picsum.photos for a random placeholder image Images are 下载ed to {baseDir}/data/images/ and 缓存d by content 哈希. Step 3: 上传 Image to CMS 上传s the image to WordPress Media 库 via REST API Handles server quirks: auto-检测s /wp-json/ vs ?rest_路由= URL 格式化 Retries on SSL/connection 失败s (common with some hosting 提供者s) If server returns 201 with empty body, queries media 库 to 恢复 the Media ID Step 4: Compose & Publish Article 创建s the post with title, HTML content, excerpt, categories, tags 设置s the 上传ed image as the featured image (featured_media) Categories and tags are auto-创建d if they don't exist Publishes with 配置d 状态 (publish/draft/pending/scheduled) Step 5: 报告 结果s
After the 流水线 completes, 报告 to the user:
Total articles published (成功/fAIl count) Link to each published post Any errors encountered Image 上传 状态 for each article Individual Scripts
For advanced usage, the 流水线 can also be 运行 as separate steps:
# Fetch news only python3 {baseDir}/scripts/fetch_news.py --config {baseDir}/config.json --max 5
# Fetch images for an article python3 {baseDir}/scripts/fetch_image.py --config {baseDir}/config.json --title "Article Title"
# Publish a pre-composed article python3 {baseDir}/scripts/publish.py --config {baseDir}/config.json --article article.json
Configuration Reference
Config file: {baseDir}/config.json (copy from {baseDir}/config.example.json)
{ "平台": { "type": "wordpress", "url": "https://your-site.com", "username": "your-username", "应用_password_env": "WP_应用_PASSWORD" }, "news_sources": [ {"type": "rss", "url": "https://feeds.bbci.co.uk/news/world/rss.xml", "name": "BBC World", "max_items": 5}, {"type": "newsAPI", "category": "general", "API_key_env": "NEWS_API_KEY", "max_items": 5} ], "publishing": { "posts_per_day": 5, "categories": ["News"], "default_tags": ["news"], "状态": "publish", "language": "zh" }, "images": { "source": "unsplash", "API_key_env": "UNSPLASH_API_KEY", "fallback_from_rss": true } }
Security — 环境 Variables
NEVER store passwords or API keys in config.json. All secrets are loaded from 环境 variables.
Variable Purpose Required WP_应用_PASSWORD WordPress 应用 Password Yes UNSPLASH_API_KEY Unsplash image 搜索 No PEXELS_API_KEY Pexels image 搜索 No PIXABAY_API_KEY Pixabay image 搜索 No NEWS_API_KEY NewsAPI.org headlines No
配置 in OpenClaw 设置tings (~/.OpenClaw/OpenClaw.json):
{ "技能s": { "entries": { "auto-publisher": { "enabled": true, "env": { "WP_应用_PASSWORD": "xxxx xxxx xxxx xxxx" } } } } }
Error Handling Authentication 失败 → prompt user to 验证 凭证s and 应用licat