Summary
Add Twitch integration to enable RustyClaw agents to communicate in Twitch chat channels for livestream interactions.
Background
Twitch is the world's leading livestreaming platform with 140M+ monthly active users. Key features:
- IRC-based chat protocol
- Emote system
- Bits/subscriptions
- Whispers (DMs)
- Bot API for chat commands
Prior Art
- OpenClaw supports Twitch as one of its 18+ messenger channels
Motivation
Twitch integration enables:
- AI-powered chat moderation
- Interactive livestream agents
- Automated responses to commands
- Community engagement automation
- Integration with streaming tools
Proposed Design
-
Configuration (config.toml):
[[messengers]]
name = "twitch"
type = "twitch"
enabled = true
username = "rustyclaw_bot"
oauth_token = "$TWITCH_OAUTH_TOKEN" # oauth:abcd1234...
channels = ["#streamer1", "#streamer2"]
command_prefix = "!"
-
Core Functionality:
- Connect via IRC protocol (irc.chat.twitch.tv:6697)
- Send messages to channels
- Receive chat messages and commands
- Handle emotes and badges
- Whisper (DM) support
- Rate limiting compliance (20 messages/30s for verified bots)
-
Implementation (src/messengers/twitch.rs):
use twitch_irc::{ClientConfig, SecureTCPTransport, TwitchIRCClient, login::StaticLoginCredentials};
pub struct TwitchMessenger {
client: TwitchIRCClient<SecureTCPTransport, StaticLoginCredentials>,
channels: Vec<String>,
}
impl TwitchMessenger {
pub async fn new(username: String, oauth_token: String, channels: Vec<String>) -> Result<Self> {
let config = ClientConfig::new_simple(
StaticLoginCredentials::new(username.clone(), Some(oauth_token))
);
let (mut incoming_messages, client) =
TwitchIRCClient::<SecureTCPTransport, StaticLoginCredentials>::new(config);
// Join channels
for channel in &channels {
client.join(channel.clone());
}
Ok(Self { client, channels })
}
pub async fn send_message(&self, channel: &str, message: &str) -> Result<()> {
self.client.say(channel.to_string(), message.to_string()).await?;
Ok(())
}
pub async fn send_whisper(&self, username: &str, message: &str) -> Result<()> {
self.client.whisper(username.to_string(), message.to_string()).await?;
Ok(())
}
}
Dependencies
[dependencies]
twitch-irc = "5.0" # Official Twitch IRC client
API Features
| Feature |
Support |
| Chat messages |
✅ IRC protocol |
| Whispers (DMs) |
✅ IRC /w command |
| Emotes |
✅ Parse from message tags |
| Badges (mod, sub, etc.) |
✅ Parse from message tags |
| Bits/Cheers |
✅ Parse from message tags |
| Raids/Hosts |
✅ IRC USERNOTICE |
Acceptance Criteria
Security Considerations
- OAuth token stored in encrypted secrets vault
- Rate limit compliance to avoid bans
- Moderation log for inappropriate content
- Channel permissions and mod status awareness
Related Issues
References
Summary
Add Twitch integration to enable RustyClaw agents to communicate in Twitch chat channels for livestream interactions.
Background
Twitch is the world's leading livestreaming platform with 140M+ monthly active users. Key features:
Prior Art
Motivation
Twitch integration enables:
Proposed Design
Configuration (
config.toml):Core Functionality:
Implementation (
src/messengers/twitch.rs):Dependencies
API Features
Acceptance Criteria
docs/MESSENGER_TWITCH.mdSecurity Considerations
Related Issues
References