From bbe0bc8de3a61bfb3af278923f60d8872ef6357a Mon Sep 17 00:00:00 2001 From: jackwener Date: Mon, 9 Mar 2026 21:20:05 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20rename=20rt/unrt=20=E2=86=92=20retweet/?= =?UTF-8?q?unretweet,=20update=20SKILL.md=20+=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rename rt/unrt commands to retweet/unretweet for clarity - SKILL.md: fix Python version, add --output/--filter examples, safety notes - README.md: dynamic Chrome fingerprint, write delays, --output examples - Sync Chinese section with English changes --- README.md | 14 ++++++++++++-- SKILL.md | 10 +++++++++- pyproject.toml | 2 +- twitter_cli/cli.py | 4 ++-- uv.lock | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 380f326..24f11a2 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,10 @@ A terminal-first CLI for Twitter/X: read timelines, bookmarks, and user profiles **Auth & Anti-Detection:** - Cookie auth: use browser cookies or environment variables - Full cookie forwarding: extracts ALL browser cookies for true browser fingerprint -- TLS fingerprint impersonation: `curl_cffi` with Chrome 133 JA3/HTTP2 +- TLS fingerprint impersonation: `curl_cffi` with dynamic Chrome version matching - `x-client-transaction-id` header generation - Request timing jitter to avoid pattern detection +- Write operation delays (1.5–4s random) to mitigate rate limits - Proxy support via `TWITTER_PROXY` environment variable ### Installation @@ -89,6 +90,8 @@ twitter favorites --max 30 --json twitter search "Claude Code" twitter search "AI agent" -t Latest --max 50 twitter search "机器学习" --json +twitter search "topic" -o results.json # Save to file +twitter search "trending" --filter # Apply ranking filter # Tweet detail (view tweet + replies) twitter tweet 1234567890 @@ -100,7 +103,9 @@ twitter list 1539453138322673664 # User twitter user elonmusk twitter user-posts elonmusk --max 20 +twitter user-posts elonmusk -o tweets.json twitter likes elonmusk --max 30 +twitter likes elonmusk -o likes.json twitter followers elonmusk --max 50 twitter following elonmusk --max 50 @@ -290,9 +295,10 @@ After installation, OpenClaw can call `twitter-cli` commands directly. **认证与反风控:** - Cookie 认证:支持环境变量和浏览器自动提取 - 完整 Cookie 转发:提取浏览器中所有 Twitter Cookie -- TLS 指纹伪装:`curl_cffi` Chrome 133 JA3/HTTP2 +- TLS 指纹伪装:`curl_cffi` 动态匹配 Chrome 版本 - `x-client-transaction-id` 请求头生成 - 请求时序随机化(jitter) +- 写操作随机延迟(1.5–4 秒),降低频率风控 - 代理支持:`TWITTER_PROXY` 环境变量 ### 安装 @@ -316,6 +322,8 @@ twitter favorites # 搜索 twitter search "Claude Code" twitter search "AI agent" -t Latest --max 50 +twitter search "topic" -o results.json # 保存到文件 +twitter search "trending" --filter # 启用排序筛选 # 推文详情 twitter tweet 1234567890 @@ -326,7 +334,9 @@ twitter list 1539453138322673664 # 用户 twitter user elonmusk twitter user-posts elonmusk --max 20 +twitter user-posts elonmusk -o tweets.json twitter likes elonmusk --max 30 +twitter likes elonmusk -o likes.json twitter followers elonmusk twitter following elonmusk diff --git a/SKILL.md b/SKILL.md index 5253d38..42514ef 100644 --- a/SKILL.md +++ b/SKILL.md @@ -18,7 +18,7 @@ Use this skill when the user wants to read or interact with Twitter/X content fr ## Prerequisites ```bash -# Install (requires Python 3.10+) +# Install (requires Python 3.8+) uv tool install twitter-cli # Or: pipx install twitter-cli ``` @@ -55,6 +55,8 @@ twitter favorites --filter # Apply ranking filter twitter search "keyword" twitter search "AI agent" -t Latest --max 50 twitter search "机器学习" --json +twitter search "topic" -o results.json # Save to file +twitter search "trending" --filter # Apply ranking filter ``` ### Tweet Detail @@ -75,7 +77,9 @@ twitter list 1539453138322673664 # Fetch tweets from a Twitter List ```bash twitter user elonmusk # User profile twitter user-posts elonmusk --max 20 # User's tweets +twitter user-posts elonmusk -o tweets.json # Save to file twitter likes elonmusk --max 30 # User's likes +twitter likes elonmusk -o likes.json # Save to file twitter followers elonmusk --max 50 # User's followers twitter following elonmusk --max 50 # User's following ``` @@ -101,6 +105,8 @@ twitter feed --json > tweets.json twitter feed --input tweets.json twitter user-posts elonmusk --json | jq '.[0].text' twitter search "keyword" --json | jq 'length' +twitter search "topic" -o results.json +twitter likes elonmusk -o likes.json ``` ## Ranking Filter @@ -149,6 +155,8 @@ twitter favorites --filter ## Safety Notes +- Write operations have built-in random delays (1.5–4s) to avoid rate limits. +- TLS fingerprint and User-Agent are automatically matched to the Chrome version used. - Do not ask users to share raw cookie values in chat logs. - Prefer local browser cookie extraction over manual secret copy/paste. - If auth fails with 401/403, ask the user to re-login to `x.com`. diff --git a/pyproject.toml b/pyproject.toml index 9111d30..c918a23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "twitter-cli" -version = "0.4.4" +version = "0.4.5" description = "A CLI for Twitter/X — feed, bookmarks, and user timeline in terminal" readme = "README.md" license = "Apache-2.0" diff --git a/twitter_cli/cli.py b/twitter_cli/cli.py index 95e7c83..cac833a 100644 --- a/twitter_cli/cli.py +++ b/twitter_cli/cli.py @@ -486,7 +486,7 @@ def unlike(tweet_id): @cli.command() @click.argument("tweet_id") -def rt(tweet_id): +def retweet(tweet_id): # type: (str,) -> None """Retweet a tweet. TWEET_ID is the numeric tweet ID.""" _write_action("🔄", "Retweeting", "retweet", tweet_id) @@ -494,7 +494,7 @@ def rt(tweet_id): @cli.command() @click.argument("tweet_id") -def unrt(tweet_id): +def unretweet(tweet_id): # type: (str,) -> None """Undo a retweet. TWEET_ID is the numeric tweet ID.""" _write_action("🔄", "Undoing retweet", "unretweet", tweet_id) diff --git a/uv.lock b/uv.lock index b4dcd7f..c982d3a 100644 --- a/uv.lock +++ b/uv.lock @@ -950,7 +950,7 @@ wheels = [ [[package]] name = "twitter-cli" -version = "0.4.3" +version = "0.4.4" source = { editable = "." } dependencies = [ { name = "beautifulsoup4" },