通过 IRC 连接接入 Twitch 聊天室。OpenClaw 以 Twitch 用户(bot 账号)身份连接,接收和发送频道消息。
安装
openclaw plugins install @openclaw/twitch快速设置
- 创建专用 Twitch bot 账号
- 在 Twitch Token Generator 生成 Bot Token,选择
chat:read和chat:write权限 - 获取 Twitch 用户 ID(用于访问控制)
- 配置 OpenClaw:
{
channels: {
twitch: {
enabled: true,
username: "openclaw",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "your_channel", // 要加入的聊天室
allowFrom: ["123456789"], // 推荐:用数字 ID 而非用户名
},
},
}环境变量(默认账号)
OPENCLAW_TWITCH_ACCESS_TOKEN
访问控制
用户 ID 白名单(最安全,用户名可变):
{ channels: { twitch: { allowFrom: ["123456789"] } } }基于角色:
{ channels: { twitch: { allowedRoles: ["moderator", "vip"] } } }可用角色:"moderator"、"owner"、"vip"、"subscriber"、"all"
关闭 @mention 要求(默认 requireMention: true):
{ channels: { twitch: { accounts: { default: { requireMention: false } } } } }Token 自动刷新
Token Generator 生成的 token 无法自动刷新,需手动重新生成。若需自动刷新,在 Twitch Developer Console 创建应用:
{
channels: {
twitch: {
clientSecret: "your_client_secret",
refreshToken: "your_refresh_token",
},
},
}多账号(一个 bot 加入多个频道)
{
channels: {
twitch: {
accounts: {
channel1: { username: "openclaw", accessToken: "oauth:abc...", channel: "vevisk" },
channel2: { username: "openclaw", accessToken: "oauth:def...", channel: "secondchannel" },
},
},
},
}消息限制
- 每条消息最多 500 字符(自动按词边界分块)
- Markdown 在分块前被剥离
相关链接
- channel-routing — 消息路由机制
- channel-groups — 群组行为与 mention 门控