Files
matrix/hookshot/owncast.js
Jared Vititoe 0e275d725e refactor: replace old bot code with Matrix infra configs and scripts
- Remove obsolete Python bot (Wordle, commands, callbacks, welcome)
- Add hookshot/ — all 11 webhook transformation functions + deploy.sh
- Add cinny/ — config.json and dev-update.sh (nightly dev branch build)
- Add landing/ — matrix.lotusguild.org landing page HTML
- Add systemd/ — livekit-server, draupnir, cinny cron unit files
- Add draupnir/ — production config (access token redacted)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 10:36:51 -04:00

21 lines
1.5 KiB
JavaScript

var evtype = data.type || 'EVENT';
var ed = data.eventData || {};
var streamName = ed.name || ed.streamerName || '';
var title = ed.streamTitle || ed.title || '';
var viewers = ed.viewerCount !== undefined ? String(ed.viewerCount) : (ed.viewers !== undefined ? String(ed.viewers) : '');
var url = ed.externalURL || ed.url || ed.serverURL || '';
var chatUser = (ed.user && (ed.user.displayName || ed.user.username)) || '';
var chatMsg = ed.body || '';
var emoji, label;
if (evtype === 'STREAM_STARTED') { emoji = '🔴'; label = 'Now Live'; }
else if (evtype === 'STREAM_STOPPED') { emoji = '⚫'; label = 'Stream Ended'; }
else if (evtype === 'USER_JOINED') { emoji = '👤'; label = 'Viewer Joined'; }
else if (evtype === 'CHAT') { emoji = '💬'; label = 'Chat'; }
else { emoji = '📡'; label = evtype.replace(/_/g, ' '); }
var lines = [emoji + ' ' + label + (streamName ? ' \u2014 ' + streamName : '')];
var htmlParts = ['<b>' + emoji + ' ' + label + '</b>' + (streamName ? ': ' + streamName : '')];
if (title) { lines.push(title); htmlParts.push('<i>' + title + '</i>'); }
if (viewers) { lines.push(viewers + ' viewers'); htmlParts.push(viewers + ' viewers'); }
if (chatUser && chatMsg) { lines.push(chatUser + ': ' + chatMsg); htmlParts.push('<b>' + chatUser + '</b>: ' + chatMsg); }
if (url && evtype === 'STREAM_STARTED') { lines.push(url); htmlParts.push('<a href="' + url + '">' + url + '</a>'); }
result = { version: 'v2', plain: lines.join('\n'), html: htmlParts.join('<br>'), msgtype: 'm.notice' };