Wire it up: Twitch events, dashboard, overlay parts, layout editor removed
Twitch / server - bits via channel.bits.use (cheers + Power-ups, replaces channel.cheer); built-in channel point rewards; polls; Hype Train v2; outgoing raids. New scopes: channel:read:polls, channel:read:hype_train, channel:manage:raids (log in again). - Hype Train: alerts on start / each new level / end, plus the progress bar. - Raid send-off: start/cancel raids from the dashboard (Helix /raids); the card stays until channel.raid reports the raid happened. - StreamElements client started on boot; tip alerts. Dashboard - Twitch + StreamElements status, test buttons (poll, Hype Train bar, raid card), Raid box, activity Reload + auto-refresh, Redeems in the nav. - Two-click delete instead of browser confirm() on Media and Actions. Overlay - ?parts= splits the overlay into OBS sources: chat, alerts, poll, hypebar, raid, or exclusions like ?parts=nochat. Recommended: ?parts=chat (audio Monitor Only, chat sounds stay off stream) + ?parts=nochat. - Now playing switched off (commented, see CLAUDE.md to re-enable). Removed the layout editor and preview page; chat position/style is baked into overlay.ejs from the last saved layout (overlay_layout table kept, unused). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b28e56f991
commit
cdcd3737a7
17 changed files with 589 additions and 140 deletions
|
|
@ -1,11 +1,44 @@
|
|||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const alerts = require('../alerts');
|
||||
const twitch = require('../twitch');
|
||||
|
||||
// POST /alerts/test/:key — send a sample alert to every connected overlay (dashboard test buttons)
|
||||
// POST /alerts/test/:key: send a sample alert to every connected overlay (dashboard test buttons)
|
||||
router.post('/test/:key', (req, res) => {
|
||||
const ok = alerts.sendTest(req.params.key);
|
||||
res.status(ok ? 200 : 404).json({ ok });
|
||||
});
|
||||
|
||||
// POST /alerts/raid/start {target}: start a raid on Twitch and show the send-off card until it happens
|
||||
router.post('/raid/start', async (req, res) => {
|
||||
const me = twitch.getUser();
|
||||
const login = String(req.body.target || '').trim().replace(/^@/, '').toLowerCase();
|
||||
if (!me) return res.status(400).json({ ok: false, error: 'not connected to Twitch' });
|
||||
if (!/^[a-z0-9_]{2,25}$/.test(login)) return res.status(400).json({ ok: false, error: 'invalid channel name' });
|
||||
try {
|
||||
const u = await twitch.helix(`/users?login=${encodeURIComponent(login)}`);
|
||||
const target = u.ok ? (await u.json()).data?.[0] : null;
|
||||
if (!target) return res.status(404).json({ ok: false, error: 'channel not found' });
|
||||
const r = await twitch.helix(`/raids?from_broadcaster_id=${me.twitch_id}&to_broadcaster_id=${target.id}`, { method: 'POST' });
|
||||
if (!r.ok) {
|
||||
const body = await r.json().catch(() => ({}));
|
||||
return res.status(r.status).json({ ok: false, error: body.message || `Twitch said ${r.status}` });
|
||||
}
|
||||
let viewers = null;
|
||||
const s = await twitch.helix(`/streams?user_id=${me.twitch_id}`);
|
||||
if (s.ok) viewers = (await s.json()).data?.[0]?.viewer_count ?? null;
|
||||
alerts.raidStarted({ target: target.display_name, avatar: target.profile_image_url || null, viewers });
|
||||
res.json({ ok: true, target: target.display_name, viewers });
|
||||
} catch (e) { res.status(500).json({ ok: false, error: e.message }); }
|
||||
});
|
||||
|
||||
// POST /alerts/raid/cancel: cancel the pending raid on Twitch and remove the card
|
||||
router.post('/raid/cancel', async (req, res) => {
|
||||
const me = twitch.getUser();
|
||||
if (!me) return res.status(400).json({ ok: false, error: 'not connected to Twitch' });
|
||||
const r = await twitch.helix(`/raids?broadcaster_id=${me.twitch_id}`, { method: 'DELETE' }).catch(e => ({ ok: false, status: 500, e }));
|
||||
alerts.raidCancelled();
|
||||
res.status(r.ok || r.status === 404 ? 200 : r.status).json({ ok: r.ok || r.status === 404 });
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue