Discord bot to write message if Twitch stream goes online
Find a file
2026-06-13 09:00:41 +02:00
.forgejo/workflows update test 2026-06-09 09:57:52 +02:00
.github/workflows tests to workflow 2025-11-01 18:13:32 +01:00
config add NTP time 2026-06-09 20:16:36 +02:00
scripts Restructured, code optimized 2025-11-01 18:05:19 +01:00
src set vars only when leet activated 2026-06-10 13:48:47 +02:00
.gitignore Restructured, code optimized 2025-11-01 18:05:19 +01:00
docker-compose.build.yml change to webhook only 2026-06-09 09:41:11 +02:00
docker-compose.yml change docker-compose image 2026-06-09 12:54:09 +02:00
DOCKER.md Restructured, code optimized 2025-11-01 18:05:19 +01:00
Dockerfile update versions 2026-06-09 09:57:44 +02:00
LICENSE Initial commit 2023-06-29 20:00:22 +00:00
README.md change to webhook only 2026-06-09 09:41:11 +02:00
renovate.json chore(deps): add renovate.json 2026-06-09 19:01:37 +00:00
requirements.txt add NTP time 2026-06-09 20:16:36 +02:00

DiscordStreamBot

Sends a Discord notification via webhook when a Twitch streamer goes live. No Discord bot token required — only webhook URLs.

Features

  • Live stream notifications with thumbnail and title
  • Multiple streamers monitored in a single batched API call
  • Automatic Twitch token refresh with 401/429 handling
  • Optional 1337 message via a separate webhook
  • Debug log forwarding to Discord webhook
  • Configurable poll interval
  • No disk writes — thumbnails are kept in memory

Project Structure

src/
  main.py           — Entry point, logging setup
  func/
    models.py       — StreamInfo dataclass
    twitch.py       — Twitch API client
    webhook.py      — Discord webhook sender
    watcher.py      — Main polling loop
config/
  config.ini.dist   — Configuration template
Dockerfile
docker-compose.yml          — Pre-built image
docker-compose.build.yml    — Local build
requirements.txt

Prerequisites

  • Python 3.11+
  • A Twitch application for client_id and client_secret
  • One or two Discord webhook URLs (channel settings → Integrations → Webhooks)

Configuration

Copy the template and fill in your values:

cp config/config.ini.dist config.ini
[DEFAULT]
LOG_LEVEL      = INFO   # DEBUG, INFO, WARNING, ERROR
poll_interval  = 60     # Seconds between Twitch checks

[DISCORD]
webhook_url       =           # Webhook for stream notifications
leet_webhook_url  =           # Webhook for 1337 message (optional)
message           = :red_circle: {user} ist live!
leet_user         =           # Discord user ID to mention at 13:37 (optional)
webhook_username  =           # Override webhook display name (optional)
webhook_avatar_url =          # Override webhook avatar URL (optional)

[TWITCH]
client_id     =
client_secret =
streams       = streamer1,streamer2,streamer3

When LOG_LEVEL = DEBUG, all log output is also forwarded to webhook_url (batched per tick).

Running Locally

pip install -r requirements.txt
cp config/config.ini.dist config.ini
# edit config.ini
python src/main.py

Docker

Pre-built image

cp config/config.ini.dist config.ini
# edit config.ini
docker compose up -d

Local build

docker compose -f docker-compose.build.yml up -d --build

Rebuild from scratch

docker compose -f docker-compose.build.yml down --rmi all
docker compose -f docker-compose.build.yml up -d --build

Logs

docker compose logs -f

Getting Credentials

Twitch:

  1. Go to dev.twitch.tv/console
  2. Create a new application (category: anything, OAuth redirect: http://localhost)
  3. Copy Client ID and generate a Client Secret

Discord Webhook:

  1. Open channel settings → Integrations → Webhooks
  2. Create a new webhook and copy the URL
  3. Repeat for a second channel if you want a separate 1337 webhook

License

See LICENSE.