Notification-Bot: Discord-Benachrichtigungen für Streams

- Neues Notification-Plugin mit eigenem Discord-Bot
- Admin-Modal im Streaming-Tab für Channel-Konfiguration
- Automatische Benachrichtigungen bei Stream-Start/Ende
- Stream-Links mit Passwort-Hinweis in Discord-Embeds
- Konfigurierbare Events pro Channel (stream_start, stream_end)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel 2026-03-08 19:29:36 +01:00
parent b25ae7990b
commit 1cf79ef917
5 changed files with 672 additions and 0 deletions

View file

@ -3,6 +3,7 @@ import { WebSocketServer, WebSocket } from 'ws';
import crypto from 'node:crypto';
import type { Plugin, PluginContext } from '../../core/plugin.js';
import { sseBroadcast } from '../../core/sse.js';
import { notifyStreamStart, notifyStreamEnd } from '../notifications/index.js';
// ── Types ──
@ -73,6 +74,19 @@ function endStream(streamId: string, reason: string): void {
broadcaster.broadcastStreamId = undefined;
}
// Send Discord notification
const durationMs = Date.now() - new Date(stream.startedAt).getTime();
const durationMin = Math.floor(durationMs / 60000);
const durationH = Math.floor(durationMin / 60);
const durationM = durationMin % 60;
const durationStr = durationH > 0 ? `${durationH}h ${durationM}m` : `${durationM}m`;
notifyStreamEnd({
broadcasterName: stream.broadcasterName,
title: stream.title,
viewerCount: stream.viewerCount,
duration: durationStr,
}).catch(err => console.error('[Streaming] Notification error:', err));
streams.delete(streamId);
broadcastStreamStatus();
console.log(`[Streaming] Stream "${stream.title}" ended: ${reason}`);
@ -130,6 +144,13 @@ function handleSignalingMessage(client: WsClient, msg: any): void {
}
}
console.log(`[Streaming] ${name} started "${title}" (${streamId.slice(0, 8)})`);
// Send Discord notification
notifyStreamStart({
streamId,
broadcasterName: name,
title,
hasPassword: password.length > 0,
}).catch(err => console.error('[Streaming] Notification error:', err));
break;
}