介绍
# chirp
使用 OpenClaw 浏览器工具操作 X/Twitter。bird CLI 的基于浏览器的替代方案。
## Prerequisites
### 环境要求 - 已启用 browser 工具的 OpenClaw - `openclaw` browser profile - 已完成 X/Twitter 账号登录
### 如果是无头服务器 (Headless)
需要 Xvfb 虚拟显示(参考 spool 技能的 Prerequisites)
### 登录(仅需一次)
``` browser action=start profile=openclaw browser action=open profile=openclaw targetUrl="https://x.com/login" # 사용자에게 수동 로그인 요청 ```
---
## 用法
### 1. 读取时间线
``` browser action=open profile=openclaw targetUrl="https://x.com/home" browser action=snapshot profile=openclaw compact=true ```
在每个 article 中可以查看作者、内容、点赞/转推/回复数量。
### 2. 发布推文
**Step 1: 在主页找到文本框** ``` browser action=open profile=openclaw targetUrl="https://x.com/home" browser action=snapshot profile=openclaw compact=true ``` → 找到 `textbox "Post text"` ref
**Step 2: 输入内容** ``` browser action=act profile=openclaw request={"kind":"click","ref":"<textbox-ref>"} browser action=act profile=openclaw request={"kind":"type","ref":"<textbox-ref>","text":"트윗 내용"} ```
**Step 3: 点击 Post 按钮** ``` browser action=snapshot profile=openclaw compact=true ``` → 找到 `button "Post"` ref(非 disabled 状态) ``` browser action=act profile=openclaw request={"kind":"click","ref":"<post-ref>"} ```
### 3. 点赞
在时间线的 article 中找到 `button "Like"` 或 `button "X Likes. Like"` ref,然后执行: ``` browser action=act profile=openclaw request={"kind":"click","ref":"<like-ref>"} ```
### 4. 转推
找到 `button "Repost"` 或 `button "X reposts. Repost"` ref,然后执行: ``` browser action=act profile=openclaw request={"kind":"click","ref":"<repost-ref>"} browser action=snapshot profile=openclaw compact=true # "Repost" 옵션 선택 browser action=act profile=openclaw request={"kind":"click","ref":"<repost-option-ref>"} ```
### 5. 回复
**方法 1: 在时间线中** ``` browser action=act profile=openclaw request={"kind":"click","ref":"<reply-button-ref>"} browser action=snapshot profile=openclaw compact=true # 답글 입력창에 텍스트 입력 후 Reply 버튼 클릭 ```
**方法 2: 在推文页面中** ``` browser action=open profile=openclaw targetUrl="https://x.com/username/status/1234567890" browser action=snapshot profile=openclaw compact=true # 답글 입력창 찾아서 입력 ```
### 6. 查看个人资料
``` browser action=open profile=openclaw targetUrl="https://x.com/username" browser action=snapshot profile=openclaw compact=true ```
### 7. 搜索
``` browser action=open profile=openclaw targetUrl="https://x.com/search?q=검색어&src=typed_query" browser action=snapshot profile=openclaw compact=true ```
### 8. 关注
在个人资料页面找到 `button "Follow"` ref,然后执行: ``` browser action=act profile=openclaw request={"kind":"click","ref":"<follow-ref>"} ```
---
## 核心要点
1. **先执行 snapshot** - 所有操作前先确认当前状态 2. **ref 每次都会变化** - 必须始终从 snapshot 中重新查找 3. **compact=true** - 节省 token 4. **article 结构** - 每条推文是一个 article 元素,内部包含作者/内容/按钮 5. **发布前确认** - 请用户确认内容
---
## 故障排除
| 问题 | 解决方案 | |------|--------| | browser 无法使用 | 检查 Xvfb、DISPLAY=:99,重启 Gateway | | 无法登录 | 前往 `/login` 后手动登录 | | Post 按钮处于 disabled 状态 | 检查文本输入 | | 达到频率限制 (Rate limit) | 稍作等待后重试 |
---
## vs bird CLI
| 功能 | bird CLI | chirp (browser) | |------|----------|-----------------| | 安装 | 需要 brew | 只需 Xvfb | | 认证 | 提取 Cookie | 浏览器会话 | | 稳定性 | 基于 API | 依赖 UI(可能会变动)| | 速度 | 快 | 稍慢 |