TTS redeems, skip button, per-source chat placement

- Redeem variations can have a TTS voice: the viewer's text is cleaned
  (links out, repeats collapsed, max length, blocked words -> not read),
  spoken as "<name> says: ..." and shown as the big paper note; the
  variation's sound is not played when TTS is on (picker greyed out)
- Settings: TTS max length, say-the-name, blocked words (never sent to
  overlay pages: db.getOverlaySettings)
- Dashboard "Skip current alert" -> /alerts/skip -> overlay skips it
- db.migrate()/addColumn: new columns on existing databases
- Chat: ?chat=left,top,width,height and ?chatflow=up per browser source
  (e.g. the Intermission panel); default unchanged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-11-21 14:34:41 +02:00
parent b5a81bdb15
commit 4fda6060bf
16 changed files with 228 additions and 28 deletions

View file

@ -2,6 +2,7 @@ const express = require('express');
const router = express.Router();
const alerts = require('../alerts');
const twitch = require('../twitch');
const ws = require('../ws');
// POST /alerts/test/:key: send a sample alert to every connected overlay (dashboard test buttons)
router.post('/test/:key', (req, res) => {
@ -9,6 +10,13 @@ router.post('/test/:key', (req, res) => {
res.status(ok ? 200 : 404).json({ ok });
});
// POST /alerts/skip: stop the alert on screen right now (e.g. a TTS message), the queue carries on
router.post('/skip', (req, res) => {
ws.broadcast({ type: 'alert_skip' });
console.log('[alerts] skip requested from the dashboard');
res.json({ ok: true });
});
// 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();

View file

@ -18,10 +18,21 @@ function partsFrom(q) {
return asked.length ? asked : PARTS;
}
// ?chat=left,top,width,height chat box in px of the 1920x1080 page (e.g. Intermission panel: 130,640,700,360)
// ?chatflow=up|down up = newest at the bottom (normal chat); down (default) = newest on top, under the camera
function chatBoxFrom(q) {
const n = String(q || '').split(',').map(Number);
if (n.length !== 4 || n.some(x => !isFinite(x))) return null;
const [l, t, w, h] = n;
if (w < 50 || h < 50 || l < -1920 || t < -1080 || l > 1920 || t > 1080 || w > 1920 || h > 1080) return null;
return { left: Math.round(l), top: Math.round(t), width: Math.round(w), height: Math.round(h) };
}
router.get('/:uuid', (req, res) => {
const settings = db.getSettings();
const settings = db.getOverlaySettings();
if (req.params.uuid !== settings.overlay_id) return res.status(404).send('Overlay not found');
res.render('overlay', { layout: false, settings, parts: partsFrom(req.query.parts) });
res.render('overlay', { layout: false, settings, parts: partsFrom(req.query.parts),
chatBox: chatBoxFrom(req.query.chat), chatFlow: req.query.chatflow === 'up' ? 'up' : 'down' });
});
module.exports = router;

View file

@ -62,6 +62,7 @@ router.get('/', async (req, res) => {
res.render('redeems', {
groups, twitchOk: !!fromTwitch, rarity: redeems.RARITY,
sounds: soundOptions(),
ttsVoices: db.getAllTtsVoices(),
stickers: [
...listDir('alerts/stickers', /\.(png|webp|gif)$/i).map(f => ({ url: `/alerts/stickers/${f}`, label: f.replace(/\.\w+$/, '') })),
...listDir('alerts/art', /\.(png|webp|gif)$/i).map(f => ({ url: `/alerts/art/${f}`, label: f.replace('_Contrast', '').replace(/\.\w+$/, '') })),
@ -93,6 +94,7 @@ router.post('/variation/:id', (req, res) => {
caption: (b.caption || '').trim() || 'redeemed it! ♡',
art: b.art || '',
enabled: b.enabled === 'on' ? 1 : 0,
tts_voice_id: db.getTtsVoice(parseInt(b.tts_voice_id, 10)) ? parseInt(b.tts_voice_id, 10) : null,
});
back(res, v);
});

View file

@ -25,12 +25,15 @@ router.post('/', (req, res) => {
gap_audio_min_volume: flt(b.gap_audio_min_volume, 0.2),
gap_audio_max_volume: flt(b.gap_audio_max_volume, 1.0),
gap_audio_loud_after: int(b.gap_audio_loud_after, 3600),
tts_max_chars: Math.max(20, Math.min(300, int(b.tts_max_chars, 200))),
tts_say_name: b.tts_say_name === 'on' ? 1 : 0,
tts_blocklist: String(b.tts_blocklist || '').slice(0, 20000),
custom_css: b.custom_css || '',
custom_js: b.custom_js || '',
});
// Push updated settings to all connected overlays so they don't need a page reload
ws.broadcast({ type: 'settings_update', settings: db.getSettings() });
ws.broadcast({ type: 'settings_update', settings: db.getOverlaySettings() });
console.log(`[settings] Saved — channel: ${b.channel}, gap_audio: ${b.gap_audio_enabled === 'on'}`);
res.redirect('/settings');