twitch-enhancer
twitch-enhancer copied to clipboard
Implement chat monitor for cross-platform keyword detection
Adds opt-in chat monitoring across Twitch and Kick channels with keyword-based notifications. Users can monitor up to 50 channels and receive real-time alerts when specified keywords appear in chat.
Architecture
Background Service
- WebSocket IRC connectors for Twitch (TMI) and Kick (Pusher) with automatic reconnection
- Keyword matching with case-insensitive detection
- Message queue stores last 100 matches
- Auto-starts/stops based on settings changes via Chrome storage listener
Settings Integration
- New "Chat Monitor" tab with toggle, channel list (platform + name), and keyword array
- Shared storage across platforms - channels/keywords from either platform apply globally
- Array field validation enforces 50 channel limit
UI Components
- Monitor button adjacent to settings button on both platforms
- Popup menu displays recent matches with highlighted keywords, timestamps, and platform/channel context
- Notification badge appears on new matches via Chrome runtime messaging
Example Usage
User enables monitor in settings:
{
chatMonitorEnabled: true,
chatMonitorChannels: [
{ platform: "twitch", channel: "xqc" },
{ platform: "kick", channel: "trainwreckstv" }
],
chatMonitorKeywords: ["essa", "!drops"]
}
Background service connects to IRC, detects keywords, sends to content script:
// Background worker
chatMonitorService.start(channels, keywords);
// On match
chrome.runtime.sendMessage({
action: "chatMonitorPing",
payload: { platform, channel, username, message, keyword, timestamp }
});
Implementation Notes
- Feature disabled by default (opt-in)
- IRC connections use anonymous authentication (no OAuth required)
- Twitch connector sends PING every 60s, Kick every 30s
- Exponential backoff for reconnection (max 5 attempts)
- Worker API actions:
getChatMonitorMatches,clearChatMonitorMatches,getChatMonitorStatus
Original prompt
This section details on the original issue you should resolve
<issue_title>feature: chat monitor</issue_title> <issue_description>we need to implement a "chat monitor" and it should work like this:
- in settings on both platforms we need a component (like the watchtime list) with shared storage. here i can add streamer names and their platforms, for example platform: kick, channel: igorovh (let's set a limit of 50 channels for now)
- the whole chat monitor must be opt-in/opt-out (turned off by default)
- we need a background script that connects to twitch and kick irc. it should handle error messages if the connection fails.
- we also need a keyword list in settings. if someone on the connected chats sends a message containing a keyword (e.g. "essa"), it triggers a ping.
- the ping should be sent via our system to transfer events from background to content scripts. we receive the ping on the page (not background) and display it to the user.
- create a new component for the ping menu located next to the settings button.</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes enhancer-app/enhancer#127
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.