fix: warn when querying other users' likes (private since Jun 2024)

Twitter/X made all likes private since June 2024. The likes command now:
- Detects if the target user differs from the authenticated user
- Shows a clear warning that only your own likes are visible
- Updated SKILL.md and README.md with likes privacy limitation

Closes #8
This commit is contained in:
jackwener
2026-03-11 12:34:17 +08:00
parent f31830f058
commit e9efa11fa5
3 changed files with 29 additions and 4 deletions

View File

@@ -110,7 +110,7 @@ twitter list 1539453138322673664
twitter user elonmusk twitter user elonmusk
twitter user-posts elonmusk --max 20 twitter user-posts elonmusk --max 20
twitter user-posts elonmusk -o tweets.json twitter user-posts elonmusk -o tweets.json
twitter likes elonmusk --max 30 twitter likes elonmusk --max 30 # ⚠️ own likes only (private since Jun 2024)
twitter likes elonmusk -o likes.json twitter likes elonmusk -o likes.json
twitter followers elonmusk --max 50 twitter followers elonmusk --max 50
twitter following elonmusk --max 50 twitter following elonmusk --max 50
@@ -360,7 +360,7 @@ twitter list 1539453138322673664
twitter user elonmusk twitter user elonmusk
twitter user-posts elonmusk --max 20 twitter user-posts elonmusk --max 20
twitter user-posts elonmusk -o tweets.json twitter user-posts elonmusk -o tweets.json
twitter likes elonmusk --max 30 twitter likes elonmusk --max 30 # ⚠️ 仅可查看自己的点赞2024年6月起平台已私密化
twitter likes elonmusk -o likes.json twitter likes elonmusk -o likes.json
twitter followers elonmusk twitter followers elonmusk
twitter following elonmusk twitter following elonmusk

View File

@@ -145,7 +145,7 @@ twitter tweet 1234567890 # Tweet detail + replies
twitter tweet https://x.com/user/status/12345 # Accepts URL twitter tweet https://x.com/user/status/12345 # Accepts URL
twitter list 1539453138322673664 # List timeline twitter list 1539453138322673664 # List timeline
twitter user-posts elonmusk --max 20 # User's tweets twitter user-posts elonmusk --max 20 # User's tweets
twitter likes elonmusk --max 30 # User's likes twitter likes elonmusk --max 30 # User's likes (own only, see note)
twitter followers elonmusk --max 50 # Followers twitter followers elonmusk --max 50 # Followers
twitter following elonmusk --max 50 # Following twitter following elonmusk --max 50 # Following
``` ```
@@ -282,6 +282,7 @@ twitter bookmarks --filter
- **No notifications** — can't read notifications - **No notifications** — can't read notifications
- **No polls** — can't create polls - **No polls** — can't create polls
- **Single account** — one set of credentials at a time - **Single account** — one set of credentials at a time
- **Likes are private** — Twitter/X made all likes private since June 2024. `twitter likes` only works for your own account
## Safety Notes ## Safety Notes

View File

@@ -539,7 +539,11 @@ def search(ctx, query, product, max_count, as_json, as_yaml, output_file, do_fil
@click.pass_context @click.pass_context
def likes(ctx, screen_name, max_count, as_json, as_yaml, output_file, do_filter): def likes(ctx, screen_name, max_count, as_json, as_yaml, output_file, do_filter):
# type: (Any, str, int, bool, bool, Optional[str], bool) -> None # type: (Any, str, int, bool, bool, Optional[str], bool) -> None
"""Show tweets liked by a user. SCREEN_NAME is the @handle (without @).""" """Show tweets liked by a user. SCREEN_NAME is the @handle (without @).
NOTE: Twitter/X made all likes private since June 2024. You can only view
your own likes. Querying another user's likes will return empty results.
"""
screen_name = screen_name.lstrip("@") screen_name = screen_name.lstrip("@")
compact = ctx.obj.get("compact", False) compact = ctx.obj.get("compact", False)
config = load_config() config = load_config()
@@ -549,6 +553,26 @@ def likes(ctx, screen_name, max_count, as_json, as_yaml, output_file, do_filter)
if rich_output: if rich_output:
console.print("👤 Fetching @%s's profile..." % screen_name) console.print("👤 Fetching @%s's profile..." % screen_name)
profile = client.fetch_user(screen_name) profile = client.fetch_user(screen_name)
# Warn if querying another user's likes (Twitter made likes private since June 2024)
try:
me = client.fetch_me()
if me.screen_name.lower() != screen_name.lower():
if rich_output:
console.print(
"\n[yellow]⚠️ Twitter/X made all likes private since June 2024. "
"You can only view your own likes. "
"Querying @%s's likes will likely return empty results.[/yellow]\n" % screen_name
)
else:
logger.warning(
"Twitter/X made likes private (June 2024). "
"Only your own likes are visible. @%s's likes will likely be empty.",
screen_name,
)
except Exception:
pass # Don't block the command if whoami fails
_fetch_and_display( _fetch_and_display(
lambda count: client.fetch_user_likes(profile.id, count), lambda count: client.fetch_user_likes(profile.id, count),
"@%s likes" % screen_name, "❤️", max_count, as_json, as_yaml, output_file, do_filter, config, "@%s likes" % screen_name, "❤️", max_count, as_json, as_yaml, output_file, do_filter, config,