Auto-Tweet Agent — OpenClaw Skill
Safe, open-source Twitter/X automation via twikit.
Replaces openclaw-x with fully auditable Python code.
Overview
This skill lets you control a Twitter/X account through natural language.
The local API runs on http://localhost:19816 and wraps the open-source
twikit library (4.1K+ ⭐, MIT license).
No closed-source binaries. No cookie theft risk. Fully transparent.
Prerequisites
The Auto-Tweet server must be running:
CODEBLOCK0
Available Actions
Post a tweet
CODEBLOCK1
Post a tweet with media
CODEBLOCK2
Reply to a tweet
CODEBLOCK3
Quote tweet
CODEBLOCK4
Search tweets
CODEBLOCK5
Search users
CODEBLOCK6
Get timeline (For You)
CODEBLOCK7
Get timeline (Following)
CODEBLOCK8
Like a tweet
CODEBLOCK9
Unlike a tweet
CODEBLOCK10
Retweet
CODEBLOCK11
Undo retweet
CODEBLOCK12
Bookmark a tweet
CODEBLOCK13
Get bookmarks
CODEBLOCK14
Get user profile
CODEBLOCK15
Get user tweets
CODEBLOCK16
Get a specific tweet
CODEBLOCK17
Delete a tweet
CODEBLOCK18
Get trending topics
CODEBLOCK19
Send a DM
CODEBLOCK20
Follow / Unfollow
CODEBLOCK21
Get notifications
CODEBLOCK22
Schedule a tweet
CODEBLOCK23
Check rate limits
CODEBLOCK24
Health check
CODEBLOCK25
Rate Limits (Built-in Safety)
| Limit | Default | Purpose |
|---|
| API calls/hour | 30 | Prevent hourly burst |
| API calls/day |
200 | Match normal usage |
| Tweets/day | 20 | Conservative posting |
All limits are configurable in config.json.
Error Handling
All endpoints return standard HTTP status codes:
- -
200 — Success - INLINECODE3 — Bad request (invalid parameters)
- INLINECODE4 — Session expired (restart server)
- INLINECODE5 — Account issue (suspended/locked)
- INLINECODE6 — Duplicate tweet
- INLINECODE7 — Rate limit exceeded
- INLINECODE8 — Twitter API error
Security Notes
- - Server binds to
127.0.0.1 only (localhost) — no external access - Credentials stay in local INLINECODE10
- Cookies saved locally in INLINECODE11
- All code is open-source Python — fully auditable
- No telemetry, no external callbacks
- Rate limiter protects against accidental overuse
自动推文代理 — OpenClaw 技能
通过 twikit 实现安全、开源的 Twitter/X 自动化。
用完全可审计的 Python 代码替代 openclaw-x。
概述
该技能允许您通过自然语言控制 Twitter/X 账户。
本地 API 运行在 http://localhost:19816,并封装了开源
twikit 库(4.1K+ ⭐,MIT 许可证)。
无闭源二进制文件。无 Cookie 窃取风险。完全透明。
前提条件
必须运行 Auto-Tweet 服务器:
bash
cd ~/.openclaw/skills/auto-tweet
python main.py
可用操作
发布推文
bash
curl -X POST http://localhost:19816/tweet \
-H Content-Type: application/json \
-d {text: 来自 OpenClaw 的问候!}
发布带媒体的推文
bash
curl -X POST http://localhost:19816/tweet \
-H Content-Type: application/json \
-d {text: 看看这个!, media_paths: [/path/to/image.jpg]}
回复推文
bash
curl -X POST http://localhost:19816/tweet \
-H Content-Type: application/json \
-d {text: 好观点!, reply
to: TWEETID}
引用推文
bash
curl -X POST http://localhost:19816/tweet \
-H Content-Type: application/json \
-d {text: 这太棒了!, quote
url: https://x.com/user/status/TWEETID}
搜索推文
bash
curl http://localhost:19816/search?q=AI+Agent&type=Latest&count=10
搜索用户
bash
curl http://localhost:19816/search/users?q=openai&count=5
获取时间线(为你推荐)
bash
curl http://localhost:19816/timeline?count=20
获取时间线(关注)
bash
curl http://localhost:19816/timeline/following?count=20
点赞推文
bash
curl -X POST http://localhost:19816/like \
-H Content-Type: application/json \
-d {tweet
id: TWEETID}
取消点赞推文
bash
curl -X POST http://localhost:19816/unlike \
-H Content-Type: application/json \
-d {tweet
id: TWEETID}
转发
bash
curl -X POST http://localhost:19816/retweet \
-H Content-Type: application/json \
-d {tweet
id: TWEETID}
取消转发
bash
curl -X POST http://localhost:19816/unretweet \
-H Content-Type: application/json \
-d {tweet
id: TWEETID}
收藏推文
bash
curl -X POST http://localhost:19816/bookmark \
-H Content-Type: application/json \
-d {tweet
id: TWEETID}
获取收藏
bash
curl http://localhost:19816/bookmarks?count=20
获取用户资料
bash
curl http://localhost:19816/user/elonmusk
获取用户推文
bash
curl http://localhost:19816/user/elonmusk/tweets?type=Tweets&count=10
获取特定推文
bash
curl http://localhost:19816/tweet/TWEET_ID
删除推文
bash
curl -X DELETE http://localhost:19816/tweet/TWEET_ID
获取热门话题
bash
curl http://localhost:19816/trends?category=trending
发送私信
bash
curl -X POST http://localhost:19816/dm \
-H Content-Type: application/json \
-d {user
id: USERID, text: 你好!}
关注 / 取消关注
bash
curl -X POST http://localhost:19816/follow/USER_ID
curl -X POST http://localhost:19816/unfollow/USER_ID
获取通知
bash
curl http://localhost:19816/notifications?type=Mentions&count=20
定时推文
bash
curl -X POST http://localhost:19816/schedule \
-H Content-Type: application/json \
-d {text: 定时推文!, scheduled_at: 1735689600}
检查频率限制
bash
curl http://localhost:19816/rate_limits
健康检查
bash
curl http://localhost:19816/
频率限制(内置安全机制)
| 限制 | 默认值 | 目的 |
|---|
| API 调用/小时 | 30 | 防止每小时突发 |
| API 调用/天 |
200 | 匹配正常使用 |
| 推文/天 | 20 | 保守发布 |
所有限制可在 config.json 中配置。
错误处理
所有端点返回标准 HTTP 状态码:
- - 200 — 成功
- 400 — 错误请求(无效参数)
- 401 — 会话过期(重启服务器)
- 403 — 账户问题(已暂停/锁定)
- 409 — 重复推文
- 429 — 超出频率限制
- 500 — Twitter API 错误
安全说明
- - 服务器仅绑定到 127.0.0.1(本地主机)— 无外部访问
- 凭据保存在本地 config.json 中
- Cookie 本地保存在 cookies.json 中
- 所有代码均为开源 Python — 完全可审计
- 无遥测,无外部回调
- 频率限制器防止意外过度使用