Social Reader Skill
This skill provides a social media content scraping and monitoring workflow. It offers two usage modes:
- - Interactive Mode: Agent fetches a single post in real-time for reading, discussion, or reply generation within a conversation.
- Pipeline Mode: Background batch patrol of sources, with LLM distillation and review notifications.
Dependencies
CODEBLOCK0
Configuration Files
| File | Purpose |
|---|
| INLINECODE0 | LLM system prompt for the Processor node |
| INLINECODE1 |
List of monitored accounts and fetch intervals (pipeline mode) |
|
input_urls.txt | Manually entered post URLs (one per line,
# for comments) |
|
seen_ids.json | Deduplication cache for seen post IDs (pipeline mode only) |
|
pending_tweets.json | Queue of unprocessed posts from the Watcher |
|
drafts.json | LLM-distilled drafts from the Processor |
|
archive.json | Archived history records |
Environment Variables (required only for Pipeline Mode Processor)
| Variable | Description | Default |
|---|
| INLINECODE8 | LLM API key (required) | None |
| INLINECODE9 |
API endpoint |
https://api.openai.com/v1 |
|
LLM_MODEL | Model name |
gpt-4o-mini |
Mode 1: Agent Interactive Call (Recommended)
When a user sends a social media post link and asks you to "read and discuss" or "generate a quality reply", call fetcher.py directly — do NOT use run_pipeline.py.
INLINECODE15 triggers deduplication cache, fixed LLM distillation, and browser popups, which are unsuitable for interactive scenarios.
Usage Example
CODEBLOCK1
get_tweet() Return Structure
CODEBLOCK2
When type is "article" (long-form post), content additionally contains:
- -
title: Article title - INLINECODE21 : Preview text
- INLINECODE22 : Full article body (Markdown format)
- INLINECODE23 : Cover image URL
This call is completely stateless — it writes no cache files and triggers no notification services.
Mode 2: Background Pipeline Batch Processing
Use run_pipeline.py to chain Watcher → Processor → Action nodes. Suitable for scheduled tasks or batch processing.
Three Core Nodes
- 1. Watcher (
watcher.py)
- Reads
input_urls.txt or
sources.json, deduplicates via
seen_ids.json, writes new posts to
pending_tweets.json.
- 2. Processor (
processor.py)
- Reads
pending_tweets.json, calls LLM to generate commentary, outputs to
drafts.json.
- Requires
LLM_API_KEY environment variable.
- 3. Action (
notifier.py)
- Starts a local HTTP review server (port 18923), opens a browser review page with approve/reject/rewrite/archive controls.
CLI Examples
CODEBLOCK3
社交媒体阅读技能
该技能提供社交媒体内容抓取与监控工作流。提供两种使用模式:
- - 交互模式:代理在对话中实时获取单条帖子,用于阅读、讨论或生成回复。
- 流水线模式:后台批量巡查数据源,配合大语言模型蒸馏与审核通知。
依赖项
bash
pip install requests
配置文件
| 文件 | 用途 |
|---|
| prompt.txt | 处理器节点的大语言模型系统提示词 |
| sources.json |
监控账号列表及抓取间隔(流水线模式) |
| input_urls.txt | 手动输入的帖子链接(每行一个,#表示注释) |
| seen_ids.json | 已见帖子ID去重缓存(仅流水线模式) |
| pending_tweets.json | 观察者产生的未处理帖子队列 |
| drafts.json | 处理器经大语言模型蒸馏后的草稿 |
| archive.json | 归档历史记录 |
环境变量(仅流水线模式处理器需要)
| 变量 | 描述 | 默认值 |
|---|
| LLMAPIKEY | 大语言模型API密钥(必填) | 无 |
| LLMBASEURL |
API端点 | https://api.openai.com/v1 |
| LLM_MODEL | 模型名称 | gpt-4o-mini |
模式一:代理交互调用(推荐)
当用户发送社交媒体帖子链接并要求您阅读讨论或生成优质回复时,直接调用fetcher.py——不要使用run_pipeline.py。
run_pipeline.py会触发去重缓存、固定的大语言模型蒸馏和浏览器弹窗,不适合交互场景。
使用示例
python
import sys
skill_dir = rd:\AIWareTop\Agent\openclaw-skills\social-reader
if skill_dir not in sys.path:
sys.path.append(skill_dir)
from fetcher import get_tweet
result = get_tweet(https://x.com/user/status/123456)
if result.get(success):
content = result[content]
# 现在您可以与用户讨论内容或生成回复
get_tweet() 返回结构
json
{
source: fxtwitter,
success: true,
type: tweet,
content: {
text: 帖子正文,
author: 显示名称,
username: 用户句柄,
created_at: 发布时间,
likes: 123,
retweets: 45,
views: 6789,
replies: 10,
media: [图片链接1, 图片链接2]
}
}
当type为article(长文帖子)时,content额外包含:
- - title:文章标题
- preview:预览文本
- fulltext:文章完整正文(Markdown格式)
- coverimage:封面图片链接
此调用完全无状态——不写入缓存文件,不触发通知服务。
模式二:后台流水线批量处理
使用run_pipeline.py串联观察者→处理器→动作节点。适用于定时任务或批量处理。
三个核心节点
- 1. 观察者(watcher.py)
- 读取input
urls.txt或sources.json,通过seenids.json去重,将新帖子写入pending_tweets.json。
- 2. 处理器(processor.py)
- 读取pending_tweets.json,调用大语言模型生成评论,输出至drafts.json。
- 需要LLM
APIKEY环境变量。
- 3. 动作(notifier.py)
- 启动本地HTTP审核服务器(端口18923),打开浏览器审核页面,提供批准/拒绝/重写/归档控制。
命令行示例
bash
完整流水线
python run_pipeline.py
指定链接
python run_pipeline.py https://x.com/elonmusk/status/123456
单节点执行
python run_pipeline.py --watch-only
python run_pipeline.py --process-only
python run_pipeline.py --notify-only