Publish tweets to X (Twitter) using the official Tweepy library. Supports text-only tweets, tweets with images or videos, and returns detailed publish result...
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install x-publisher或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install x-publisher⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/x-publisher/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: X-Publisher description: Publish tweets to X (Twitter) using the official Tweepy library. Supports text-only tweets, tweets with images or videos, and returns detailed publish results including tweet ID and URL. Requires X API credentials (API Key, API Secret, Access Token, Access Token Secret). env: - X_API_KEY - X_API_SECRET - X_ACCESS_TOKEN - X_ACCESS_TOKEN_SECRET - X_BEARER_TOKEN ---
使用官方 Tweepy 库发布推文,支持纯文本、图片、视频等多种媒体类型。
pip3 install tweepy --user
- API Key - API Secret - Access Token - Access Token Secret
# 添加到 ~/.zshrc
export X_API_KEY="your-api-key"
export X_API_SECRET="your-api-secret"
export X_ACCESS_TOKEN="your-access-token"
export X_ACCESS_TOKEN_SECRET="your-access-token-secret"
export X_BEARER_TOKEN="your-bearer-token" # 可选
然后执行:
source ~/.zshrc
首次使用前,建议先验证凭证:
python3 scripts/x_publisher.py verify
输出示例:
✅ 认证成功!
👤 用户名: @your_username
📛 显示名: Your Name
👥 粉丝: 1,234
📝 推文: 5,678
python3 scripts/x_publisher.py tweet "Hello, X! This is my first tweet."
# 单张图片
python3 scripts/x_publisher.py tweet "Check out this photo!" --media /path/to/image.jpg
# 多张图片(最多4张)
python3 scripts/x_publisher.py tweet "My photo collection:" \
--media /path/to/photo1.jpg \
--media /path/to/photo2.png \
--media /path/to/photo3.gif
python3 scripts/x_publisher.py tweet "Watch this video!" --media /path/to/video.mp4
发布成功后会返回:
============================================================
✅ 推文发布成功!
============================================================
📝 推文 ID: 1234567890123456789
🔗 链接: https://twitter.com/user/status/1234567890123456789
⏰ 发布时间: 2024-02-03T15:30:45.123456
📄 内容预览: Hello, X! This is my first tweet.
============================================================
📋 JSON 输出:
{
"success": true,
"tweet_id": "1234567890123456789",
"text": "Hello, X! This is my first tweet.",
"created_at": "2024-02-03T15:30:45.123456",
"url": "https://twitter.com/user/status/1234567890123456789"
}
| 命令 | 功能 | 示例 | |------|------|------| | verify | 验证认证 | x_publisher.py verify | | tweet | 发布推文 | x_publisher.py tweet "Hello" --media photo.jpg |
| 参数 | 简写 | 说明 | 必填 | |------|------|------|------| | text | - | 推文内容 | 是 | | --media | -m | 媒体文件路径 | 否 |
限制:
限制:
❌ 认证失败: 无法获取用户信息
解决方法:
❌ 推文发布失败
错误类型: 权限不足
错误信息: You are not allowed to create a Tweet with these settings
解决方法:
❌ 推文发布失败
错误类型: 请求过于频繁
错误信息: Rate limit exceeded
解决方法:
❌ 媒体文件不存在: /path/to/image.jpg
解决方法:
# 发布每日摘要
python3 scripts/x_publisher.py tweet "📊 今日市场摘要:BTC $43,250 (+2.3%)"
# 发布截图或图表
python3 scripts/x_publisher.py tweet "📈 今日走势图" --media ~/charts/btc_today.png
#!/bin/bash
# publish_news.sh
CONTENT="🚀 重大新闻:..."
IMAGE="/path/to/news_image.jpg"
python3 scripts/x_publisher.py tweet "$CONTENT" --media "$IMAGE"
import subprocess
import json
result = subprocess.run(
['python3', 'scripts/x_publisher.py', 'tweet', 'Hello!', '--media', 'photo.jpg'],
capture_output=True,
text=True
)
# 解析 JSON 输出
output_lines = result.stdout.split('\n')
for line in output_lines:
if line.strip().startswith('{'):
tweet_info = json.loads(line)
print(f"Tweet ID: {tweet_info['tweet_id']}")
print(f"URL: {tweet_info['url']}")
| 限制类型 | 数值 | 说明 | |----------|------|------| | 推文长度 | 280 字符 | 超过将自动截断 | | 媒体数量 | 4 个 | 图片或视频混合 | | 图片大小 | 5 MB | 单张图片 | | 视频大小 | 512 MB | 单个视频 | | 视频时长 | 2分20秒 | 最大时长 | | 发布频率 | 300条/15分钟 | 速率限制 |
安装 X tweet publisher 后,可以对 AI 说这些话来触发它
Help me get started with X tweet publisher
Explains what X tweet publisher does, walks through the setup, and runs a quick demo based on your current project
Use X tweet publisher to publish tweets to X (Twitter) using the official Tweepy library
Invokes X tweet publisher with the right parameters and returns the result directly in the conversation
What can I do with X tweet publisher in my marketing & growth workflow?
Lists the top use cases for X tweet publisher, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/x-publisher/ 目录(个人级,所有项目可用),或 .claude/skills/x-publisher/(项目级)。重启 AI 客户端后,用 /x-publisher 主动调用,或让 AI 根据上下文自动发现并使用。
X tweet publisher 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
X tweet publisher 可免费安装使用。请查阅仓库了解许可证信息。
Publish tweets to X (Twitter) using the official Tweepy library. Supports text-only tweets, tweets with images or videos, and returns detailed publish result...
X tweet publisher 属于「Marketing & Growth」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my marketing & growth tasks using X tweet publisher
Identifies repetitive steps in your workflow and sets up X tweet publisher to handle them automatically