diff --git a/docs/channels/twitch.md b/docs/channels/twitch.md index 38f6a3eb8..b2ab3d0ac 100644 --- a/docs/channels/twitch.md +++ b/docs/channels/twitch.md @@ -196,6 +196,7 @@ Restrict access to specific roles: username: "mybot", token: "oauth:...", clientId: "...", + channel: "your_channel", allowedRoles: ["moderator", "vip"] } } @@ -224,6 +225,7 @@ Only allow specific Twitch user IDs (most secure): username: "mybot", token: "oauth:...", clientId: "...", + channel: "your_channel", allowFrom: ["123456789", "987654321"] } } @@ -252,6 +254,7 @@ Users in `allowFrom` bypass role checks. In this example: username: "mybot", token: "oauth:...", clientId: "...", + channel: "your_channel", allowFrom: ["123456789"], allowedRoles: ["moderator"] } @@ -274,6 +277,7 @@ Only respond when the bot is mentioned: username: "mybot", token: "oauth:...", clientId: "...", + channel: "your_channel", requireMention: true } } @@ -306,7 +310,8 @@ Config with env fallback: accounts: { default: { username: "mybot", - clientId: "your_client_id" + clientId: "your_client_id", + channel: "your_channel" // token will be read from CLAWDBOT_TWITCH_ACCESS_TOKEN } } @@ -377,6 +382,7 @@ clawdbot channels status --probe username: "mybot", token: "oauth:...", clientId: "...", + channel: "your_channel", // Temporary: allow everyone allowedRoles: ["all"] } @@ -386,7 +392,7 @@ clawdbot channels status --probe } ``` -**Check the bot is in the channel:** The bot must join the channel (either `channel: "target_channel"` or defaults to `username`). +**Check the bot is in the channel:** The bot must join the channel specified in `channel`. ### Token issues diff --git a/extensions/twitch/README.md b/extensions/twitch/README.md index f5e091b6d..73789b60b 100644 --- a/extensions/twitch/README.md +++ b/extensions/twitch/README.md @@ -1,6 +1,6 @@ # @clawdbot/twitch -Twitch channel plugin for Clawdbot. +Twitch chat plugin for Clawdbot. ## Install (local checkout) @@ -18,7 +18,7 @@ Onboarding: select Twitch and confirm the install prompt to fetch the plugin aut ## Config -Minimal config (default account): +Minimal config: ```json5 { @@ -27,137 +27,30 @@ Minimal config (default account): enabled: true, accounts: { default: { - username: "mybot", - token: "oauth:your_token_here", + username: "clawdbot", + token: "oauth:abc123...", clientId: "your_client_id_here", - }, - }, - }, - }, + channel: "vevisk" + } + } + } + } } ``` ## Setup -1. **Create a Twitch application:** - - Go to [Twitch Developer Console](https://dev.twitch.tv/console) - - Click "Register Your Application" - - Set Application Type to "Chat Bot" - - Copy the Client ID - -2. **Generate your OAuth token:** - - Use [Twitch Token Generator](https://twitchtokengenerator.com/) or [TwitchApps TMI](https://twitchapps.com/tmi/) +1. Create a Twitch application: [Twitch Developer Console](https://dev.twitch.tv/console) +2. Generate OAuth token: [Twitch Token Generator](https://twitchtokengenerator.com/) - Select scopes: `chat:read` and `chat:write` - - Copy the token (starts with `oauth:`) - -3. **Configure credentials:** - - Config: `channels.twitch.accounts.default.token` - - Or env: `CLAWDBOT_TWITCH_ACCESS_TOKEN=...` (default account only) - -4. **Start the gateway** - Twitch starts when a token is resolved - -## Token refresh (recommended) - -For long-running bots, configure automatic token refresh: - -```json5 -{ - channels: { - twitch: { - accounts: { - default: { - username: "mybot", - token: "oauth:abc123...", - clientId: "your_client_id", - clientSecret: "your_client_secret", - refreshToken: "your_refresh_token", - }, - }, - }, - }, -} -``` - -## Access control - -Allowlist by user ID (recommended): - -```json5 -{ - channels: { - twitch: { - accounts: { - default: { - username: "mybot", - token: "oauth:...", - clientId: "...", - allowFrom: ["123456789", "987654321"], - }, - }, - }, - }, -} -``` - -Role-based restrictions: - -```json5 -{ - channels: { - twitch: { - accounts: { - default: { - username: "mybot", - token: "oauth:...", - clientId: "...", - allowedRoles: ["moderator", "vip"], - }, - }, - }, - }, -} -``` - -Available roles: `"moderator"`, `"owner"`, `"vip"`, `"subscriber"`, `"all"` - -## Multiple accounts - -```json5 -{ - channels: { - twitch: { - accounts: { - main: { - username: "mybot", - token: "oauth:...", - clientId: "...", - channel: "streamer1", - }, - secondary: { - username: "mybot", - token: "oauth:...", - clientId: "...", - channel: "streamer2", - }, - }, - }, - }, -} -``` - -## Environment variables - -For the default account: - -- `CLAWDBOT_TWITCH_ACCESS_TOKEN` - OAuth token (with `oauth:` prefix) - -Restart the gateway after config changes. +3. Start the gateway ## Full documentation -See [https://docs.clawd.bot/channels/twitch](https://docs.clawd.bot/channels/twitch) for complete documentation including: +See https://docs.clawd.bot/channels/twitch for: -- Token setup options +- Token refresh setup - Access control patterns +- Multi-account configuration - Troubleshooting - Capabilities & limits diff --git a/extensions/twitch/src/types.ts b/extensions/twitch/src/types.ts index 11106ee84..1938194f5 100644 --- a/extensions/twitch/src/types.ts +++ b/extensions/twitch/src/types.ts @@ -52,7 +52,7 @@ export interface TwitchAccountConfig { /** Twitch OAuth token (requires chat:read and chat:write scopes) */ token: string; /** Twitch client ID (from Twitch Developer Portal or twitchtokengenerator.com) */ - clientId?: string; + clientId: string; /** Channel name to join (required) */ channel: string; /** Enable this account */