Twitch Clip Skill
Creates a clip of the last 30–60 seconds of a live Twitch stream via the Twitch Clips API. Includes a 30-second cooldown to prevent accidental spam clipping.
Setup
1. Create a Twitch app
- 1. Go to https://dev.twitch.tv/console/apps
- Register a new app (OAuth Redirect URL:
http://localhost, Category: Other) - Copy your Client ID and generate a Client Secret
2. Get an OAuth token
Visit this URL in your browser (replace
YOUR_CLIENT_ID):
https://id.twitch.tv/oauth2/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost&response_type=token&scope=clips:edit
Copy the
access_token from the redirect URL.
3. Set environment variables
CODEBLOCK1
To find your broadcaster ID:
CODEBLOCK2
Usage
Run the clip script:
bash scripts/create_clip.sh [duration_seconds]
- - Duration defaults to 30, max 60
- Stream must be live or the API returns a 404
Cooldown
A 30-second cooldown is enforced between clips. If a clip request comes in during cooldown:
- - Script exits with code 2 and prints remaining wait time
- Reply: INLINECODE3
- Do NOT retry automatically — wait for the next explicit clip request
Trigger phrases
- - "clip that"
- "clip the last X seconds"
- "make a clip"
- "clip it"
Response format
Success:
INLINECODE4
Cooldown active:
INLINECODE5
Not live:
INLINECODE6
Token refresh
Tokens expire. If you get a 401 error, re-authorize using the URL in Setup step 2.
Twitch片段技能
通过Twitch Clips API创建直播Twitch频道最近30-60秒的片段。包含30秒冷却时间以防止意外重复剪辑。
设置
1. 创建Twitch应用
- 1. 访问 https://dev.twitch.tv/console/apps
- 注册新应用(OAuth重定向URL:http://localhost,类别:其他)
- 复制您的客户端ID并生成客户端密钥
2. 获取OAuth令牌
在浏览器中访问此URL(替换YOUR
CLIENTID):
text
https://id.twitch.tv/oauth2/authorize?client
id=YOURCLIENT
ID&redirecturi=http://localhost&response_type=token&scope=clips:edit
从重定向URL中复制access_token。
3. 设置环境变量
bash
export TWITCH
CLIENTID=your
clientid
export TWITCH
ACCESSTOKEN=your
accesstoken
export TWITCH
BROADCASTERID=your
broadcasterid # 数字用户ID
查找您的播主ID:
bash
curl -s -H Authorization: Bearer $TWITCHACCESSTOKEN \
-H Client-Id: $TWITCHCLIENTID \
https://api.twitch.tv/helix/users | python3 -c import json,sys; print(json.load(sys.stdin)[data][0][id])
使用方法
运行剪辑脚本:
bash
bash scripts/createclip.sh [durationseconds]
- - 时长默认为30秒,最大60秒
- 直播必须处于进行中状态,否则API返回404
冷却时间
两次剪辑之间强制设置30秒冷却时间。如果在冷却期间收到剪辑请求:
- - 脚本退出代码为2,并显示剩余等待时间
- 回复:⏳ 冷却中 — 请在X秒后重试
- 不要自动重试 — 等待下一次明确的剪辑请求
触发短语
回复格式
成功:
已剪辑!🎬 https://clips.twitch.tv/
冷却中:
⏳ 冷却中 — 请在X秒后重试
未直播:
直播已离线 — 当前无法剪辑
令牌刷新
令牌会过期。如果收到401错误,请使用设置步骤2中的URL重新授权。