-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Summary
Add a x-cli watch command that continuously monitors one or more X/Twitter accounts for new posts and displays them in real-time in the terminal.
Use case: Track accounts like @CheddarFlow for live options flow alerts, breaking news accounts, or any account where timely updates matter.
Proposed CLI Interface
# Watch a single account
x-cli watch CheddarFlow
# Watch multiple accounts
x-cli watch CheddarFlow unusual_whales
# Filter by keyword/ticker
x-cli watch CheddarFlow --filter "$NVDA"
# Custom poll interval (default: 60s)
x-cli watch CheddarFlow --interval 30
# Output formats work too
x-cli -j watch CheddarFlow
x-cli -p watch CheddarFlow # pipe-friendly for downstream processing
# Desktop notifications (optional)
x-cli watch CheddarFlow --notify
# Stop after N tweets
x-cli watch CheddarFlow --max 50Implementation Plan
1. Add watch command to cli.py
- New top-level Click command
watch - Params:
usernames(multiple),--interval(default 60),--filter,--notify,--max - Resolves usernames to user IDs, then enters polling loop
2. Add polling logic to api.py
- New method
get_new_tweets(user_id, since_id)— wrapsget_timeline()withsince_idparam to only fetch tweets newer than the last seen - Twitter API v2 supports
since_idon the timeline endpoint natively
3. Watch loop (watch.py — new module)
- Core loop: poll → diff → display → sleep
- Track
last_seen_idper user to avoid duplicates - Use
since_idAPI param for efficient server-side filtering - Handle rate limits gracefully (back off on 429, show countdown)
- Clean
Ctrl+Chandling with summary on exit
4. Optional: Desktop notifications
- Use
osascripton macOS for native notifications - Fallback to terminal bell (
\a) on other platforms - Gated behind
--notifyflag
5. Optional: Keyword filtering
- Client-side text matching on tweet content
- Support multiple
--filterflags - Case-insensitive matching
6. Output integration
- Reuse existing
format_output()formatters - JSON mode: one JSON object per line (NDJSON) for streaming parsers
- Plain mode: TSV rows as tweets arrive
- Human mode: Rich panels with timestamp
Rate Limit Considerations
- Twitter API v2 timeline endpoint: 900 requests / 15 min window (bearer token)
- Default 60s interval = ~15 requests/15min per account — well within limits
- With 5 accounts at 30s interval = ~150 requests/15min — still safe
- Display rate limit status in verbose mode
Architecture Notes
- Fits cleanly into existing patterns: Click command → API client → formatter
since_idis the key — avoids fetching/diffing full timelines- No new dependencies needed (httpx handles polling fine)
- Consider
asynciofor multi-account parallel polling in future
Acceptance Criteria
-
x-cli watch <username>polls and displays new tweets in real-time - Multiple usernames supported
-
--intervalcontrols poll frequency -
--filterfilters tweets by keyword - All output modes work (
-j,-p,-md, default) - Graceful Ctrl+C with exit summary
- Rate limit handling (backoff on 429)
- Tests for polling logic and filtering
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels