How heeetz/twitch-bot works
Twitch Bot is a single-channel chat bot paired with a pywebview desktop control panel. The primary workflow receives Twitch chat, records presence and applies filters, then dispatches built-in or custom commands through permission and cooldown checks to domain services and chat output. The desktop workflow configures those runtime controls through a Python bridge. README capabilities are represented, including weather, followage, Gemini memory, filters, settings, logs, and tray controls; some subsystem links rely on README documentation because their implementation was not sampled.
Main entry points: webview_host.py Desktop host and API · registry.py Command dispatch · client.py Twitch connection · gemini_ai_service.py Gemini responses
Components 30
Twitch chat runtime
- Twitch connection
app/twitch/client.py - Chat event types
app/twitch/events.py - Command dispatch
app/commands/registry.py - Role permissions
app/twitch/permissions.py - Cooldown tracking
app/utils/cooldown.py - Built-in commands
app/commands/registry.py - Custom commands
app/custom_commands.py - Ask command
app/commands/ai.py
Domain services
- Seen-user records
app/database/repository.py - Message filters
app/services/filter_manager.py - Weather lookup
app/services/weather.py - Followage lookup
app/services/twitch.py - AI request policy
app/services/ai_request_policy.py - Gemini responses
app/services/gemini_ai_service.py - Conversation memory
app/services/memory.py
Settings and persistence
- SQLite data
app/database/database.py - Runtime controls
app/runtime_state.py - App configuration
app/config/settings.py - AI personalities
app/config/personalities.py - Command overrides
app/command_settings.py - Filter settings
app/filter_settings.py
Desktop control panel
- Desktop host and API
app/webview_host.py - Control panel
frontend/src/App.tsx - Python API client
frontend/src/bridge.ts - Recent log buffer
app/utils/logging.py - System tray
app/system_tray.py
Other components
- Chat participants
- Twitch API
- Open-Meteo
- Google Gen AI
Connections 31
- Chat participants → Twitch connection: sends chat
- Twitch connection → Chat event types: receives events
app/twitch/client.py - Twitch connection → Seen-user records: records users
app/twitch/client.py - Twitch connection → Command dispatch: dispatches chat
app/twitch/client.py - Command dispatch → Message filters: applies filters
- Command dispatch → Role permissions: checks roles
app/commands/registry.py - Command dispatch → Cooldown tracking: checks cooldowns
app/commands/registry.py - Command dispatch → Built-in commands: dispatches built-ins
app/commands/registry.py - Command dispatch → Custom commands: dispatches custom
app/commands/registry.py - Built-in commands → Weather lookup: looks up weather
- Built-in commands → Followage lookup: looks up followage
- Built-in commands → Ask command: includes ask
app/commands/ai.py - Ask command → AI request policy: checks requests
app/commands/ai.py - Ask command → Gemini responses: requests response
- Gemini responses → Conversation memory: uses memory
- Gemini responses → AI personalities: builds instructions
app/services/gemini_ai_service.py - Gemini responses → Google Gen AI: calls provider
- Weather lookup → Open-Meteo: queries weather
- Followage lookup → Twitch API: queries follows
- SQLite data → Seen-user records: stores records
app/database/database.py - Desktop host and API → Twitch connection: controls lifecycle
app/webview_host.py - Desktop host and API → Control panel: hosts interface
- Control panel → Python API client: calls API
frontend/src/App.tsx - Python API client → Desktop host and API: invokes Python API
- Desktop host and API → Runtime controls: updates controls
- Runtime controls → Command overrides: loads overrides
app/runtime_state.py - Desktop host and API → App configuration: manages settings
app/webview_host.py - Desktop host and API → Filter settings: manages filters
app/webview_host.py - Desktop host and API → Recent log buffer: reads recent logs
app/webview_host.py - Control panel → Recent log buffer: shows live logs
frontend/src/App.tsx - Desktop host and API → System tray: coordinates tray
app/webview_host.py