Let streamers set how long messages stay on screen
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 29s

Adds display_duration_seconds to the streamers table (default 10s,
with an idempotent migration for existing rows), a dashboard control
to change it, and wires the value through to the overlay via the
display_message payload instead of a hardcoded 10s.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-07-01 16:56:49 +00:00
parent fab55cde1d
commit f4d023c695
4 changed files with 87 additions and 4 deletions

12
db.js
View file

@ -18,6 +18,7 @@ db.exec(`
overlay_token TEXT UNIQUE NOT NULL,
sender_token TEXT UNIQUE NOT NULL,
tts_voice TEXT NOT NULL DEFAULT 'ru-RU-DmitryNeural',
display_duration_seconds INTEGER NOT NULL DEFAULT 10,
created_at INTEGER NOT NULL
);
@ -30,6 +31,12 @@ db.exec(`
);
`);
// Idempotent migration for databases created before display_duration_seconds existed.
const existingColumns = db.prepare('PRAGMA table_info(streamers)').all().map((c) => c.name);
if (!existingColumns.includes('display_duration_seconds')) {
db.exec('ALTER TABLE streamers ADD COLUMN display_duration_seconds INTEGER NOT NULL DEFAULT 10');
}
function generateToken() {
return crypto.randomBytes(16).toString('hex');
}
@ -75,10 +82,15 @@ function setViewerName(streamerId, googleId, displayName) {
).run(streamerId, googleId, displayName, Date.now());
}
function updateDisplayDuration(streamerId, seconds) {
db.prepare('UPDATE streamers SET display_duration_seconds = ? WHERE id = ?').run(seconds, streamerId);
}
module.exports = {
findStreamerByOverlayToken,
findStreamerBySenderToken,
getOrCreateStreamerByGoogle,
getViewerName,
setViewerName,
updateDisplayDuration,
};