Commit graph

40 commits

Author SHA1 Message Date
2659993a7d Poll card and emote effects use the corner sticker from Actions -> Alerts
The heart on the winning poll option and the picture when Twitch sends no emote were still a
fixed file name; they now come from the alert theme (placeholder when none is set).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 11:24:56 +02:00
c481ca92cb Stats per stream and period, public stats page, dashboard settings, Card alert style
Statistics
- Per day and per stream statistics (src/periodstats.js, one generic stat_day table), backfilled
  once from the older tables; Stream / Week / Month / Year / All time views, Community and Streams tabs.
- Viewer count every 5 minutes and title / category history per stream (EventSub channel.update):
  viewer graph, games played (donut), games in the streams list.
- Twitch sync (src/twitchsync.js): followers with follow dates, current subs, mods, VIPs, all-time
  bits, channel emotes, past streams from VODs. Twitch analytics CSV import (src/twitchcsv.js).
- Public stats page on its own host (Settings -> Stats and data): no message text, no bots,
  !hideme / !showme opt-out. Viewer page: roles, follow age, sub status, bits, a menu for rarely used actions.
- StreamElements watch-time importer removed (already imported minutes stay as a baseline).

Dashboard
- Settings and Actions with a left sidebar; each settings page saves only its own fields.
  Connections (Twitch, StreamElements token now set here, HUDFX), OBS links (hidden behind an eye
  toggle) with a link builder, Chat (sound picked from the media library), TTS, Stats and data,
  Backup (export / import the whole setup), Advanced. Time zone setting for the stats pages.
- Actions -> Alerts: alert style, pictures, sounds, bits tiers and card colours, stored in the
  database (src/theme.js); an old file-based theme is imported once. Alert preview page
  (/actions/alerts/preview, tools/preview/export.js for a static copy).
- Old /actions page removed; Actions = Redeems / Alerts / TTS voices / Media.

Alerts
- New plain Card style for everyone (public/alerts/card.js); Polaroid, Cassette and the TTS letter
  stay as optional looks. Redeem variations can be Card, Cassette, Sound only or Video.

Repo
- No channel data in git: the channel's art, stickers and sounds stay on disk (gitignored) and are
  picked in the dashboard; examples for the server config (apache.example.sh, .env.example).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 11:22:49 +02:00
5bf4bffaa0 Stats: move a renamed viewer's StreamElements watch time to their new name
Viewer page (import-only viewers): 'Renamed on Twitch? New name -> Move'. Moves the
imported minutes (adding to any already there) and stores old -> new in watch_alias,
which importing again applies, so the hours never jump back to the old name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:10:00 +02:00
3a312ab493 Levels: Viewer, Regular (50 h), Loyal (200 h), Veteran (1000 h)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:04:43 +02:00
207740c3e6 Levels: Regular from 20 h, Veteran from 200 h
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:01:23 +02:00
a3e862e9c2 Levels by watch time: Viewer, Regular (10 h), Veteran (50 h)
Replaces the cassette-themed point levels. Watch time = our ticks + StreamElements
import; points only rank the leaderboard, bits/subs do not buy a level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:56:22 +02:00
024934f09f Stats: tidy leaderboards (even rows, aligned values and level pills, wider Points board)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:53:18 +02:00
dd0e92c0bb Stats: one-time import of StreamElements watch time
seimport.js reads the SE channel from SE_JWT, fetches /kappa/v2/points/<ch>/watchtime
(all pages) into watch_import (login, minutes), replacing any previous import.
Imported minutes count as watch time and watch points (5 per 5 min, merged by
login) on the Stats page, leaderboards and viewer pages. Button on Stats warns that
importing again after our own tracking started double-counts those streams.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:50:04 +02:00
c364e7079b Stats page: overview, activity per day, leaderboards, top emotes/commands, viewer lookup
/stats (dashboard nav): totals, chat messages and watch hours per day (30 days,
single-series bar charts with hover), leaderboards for points (with level), watch
time, chat, bits, channel points spent; top emotes (with images) and commands.
/stats/viewer?q=: one viewer's points breakdown, watch time, messages, check-ins,
emotes, commands, actions, and 'Forget this viewer' (removal requests: stats, watch
time, raw chat, activity log). Bots (Hidden chatters) left out of everything shown.
src/points.js: the agreed point values in one place, calculated from the stats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:40:05 +02:00
1c36e80f66 Watch time: one 5-minute tick while live (lurkers included), per-stream check-ins
watchtime.js: stream.online/offline (+ Helix /streams check at start) give the live
state; every 5 min the chatter list (Helix /chat/chatters, new scope
moderator:read:chatters) gets +1 tick = 5 minutes = 5 points, overall and per day,
so watch time and points share one sync. First chat message per stream is stored as
a check-in. Without the scope the tick logs once and skips.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:35:21 +02:00
f4ee205d4a docs: import StreamElements watch time when building watch-time tracking
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:32:07 +02:00
c296e020b0 Chat stats: count bots too; hide them only when showing statistics
Hidden chatters are now counted like everyone else; statistics pages and
leaderboards filter them at display time (chatlog.isHidden / hiddenUsers), so
editing the list applies immediately without losing data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:31:17 +02:00
2991c88d9e Chat stats: points-eligible messages (1 per 5 min) and first-ever-message flag
For the planned point system (docs/PLANS.md): chat_user.scored/last_scored and
chat_user_day.scored count messages at least 5 min after the viewer's previous
counted one; chat_user.intro keeps Twitch's first-time-chatter flag. Point values
agreed: chat 10, check-in 25, first message 50, raid flat 100, watch 10 per 10 min.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:30:32 +02:00
a7a701a678 docs: point values from her (raid flat 100, chat 10, check-in 25, first message 50)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:28:42 +02:00
87d82c1a02 docs: point system draft
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:25:50 +02:00
862edf6d5d Per-viewer action statistics: rewards, Power-ups, cheers, subs, gifts, follows, raids, tips
chat_action counts every logged viewer event (via dispatch.js) per viewer and item,
with total spent (points / bits / months / subs / viewers / tip money). Keyed by
Twitch user id, or name:<login> for events without one. Hidden chatters skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:24:21 +02:00
cd751e3a07 Chat statistics: per-viewer messages, emotes, commands; raw chat kept 30 days
Server reads chat via EventSub channel.chat.message (works without OBS) and counts
each message at once into chat_user, chat_user_day, chat_emote (Twitch + 7TV by
name) and chat_command. Raw messages are a 30-day buffer (hourly cleanup); deletes,
timeouts/bans and chat clears remove stored text at once; hidden chatters are not
counted. chatlog.forgetUser() for removal requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:21:34 +02:00
30f42a65e8 docs: plans for free Power-up uses, own chat bot, chat log for statistics
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 17:16:51 +02:00
38b2bef2ec Fix: a Custom Power-up crashed the server (activity log without event type)
alerts.js named redeem alerts for the log from a map without custom_power_up, so
logActivity got event_type undefined -> SQLite NOT NULL error -> uncaught -> the
process exited (the video alert never reached the overlay). Add custom_power_up,
fall back to a generic type, and never let a failed activity-log write crash the server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:34:57 +02:00
a32a55c264 Media page shows the whole library, multi-file upload; pill pickers on Redeems
- src/library.js: one list of every media file (built-in public/alerts + uploads),
  shared by the Media page and the Redeems pickers.
- Media page rebuilt: drag & drop / multi-file upload with progress (audio, video,
  images for stickers), Videos / Sounds / Stickers & art with previews, size,
  'used by N' and a filter; only uploads can be deleted.
- Fix: /media no longer 301-redirects to /media/ (express.static redirect:false).
- Redeems: sound / video / sticker / TTS voice are pills (click to change, x to
  clear) with a type-to-search list (arrows, Enter, Esc) instead of dropdowns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:24:18 +02:00
8ac8fe024c Reward / Power-up icon as a top-left sticker on the cassette and the video box
Twitch icons of channel point rewards (custom images) and Custom Power-ups are cached
(10 min, refreshed on unknown triggers, never holding an alert more than 2 s) and
attached as alert.icon; cassette.js and video.js show it as a white-outlined sticker
on the top-left corner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:14:39 +02:00
b3caac7a31 Video Power-ups: Custom Power-ups, ?parts=video overlay, new redeems editor
- Custom Power-ups (bits) are redeem triggers: channel.custom_power_up_redemption.add
  -> redeems.handle('custom_power_up', ...) with the bits amount; listed live from
  Helix /bits/custom_power_ups on the Redeems page; labels/replay in Recent activity.
- Variations can show a video (reward_variations.video): style 'video' plays only on
  the opt-in ?parts=video overlay (public/alerts/video.js), full-screen, one at a time,
  with a yellow camcorder box ("TRIGGERED <name>", viewer, bits, POWER-UP) in the alert
  corner. Any source size; 2560x1440 like HUDFX gives sharper video.
- Redeems page rewritten as one editor: Display (Cassette / Sound only / Video),
  volume slider, sticker thumbnails, live % chances, one Save button + Ctrl+S
  (POST /redeems/save), tests/add/delete save first, unsaved edits kept as a browser
  draft with an inline restore bar (no dialogs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:10:56 +02:00
19a0965eb2 Activity replay, HUDFX in the overlay, chat filter, redeem art fix
- Dashboard Recent activity: readable details (reward name, cost, variation,
  rarity, TTS, viewer message; sub tier/months; bits; raids; polls), local
  times, and a Replay button. Each row now stores the overlay message that was
  shown (activity_log.replay_json); older redeem/raid rows are rebuilt from the
  raw Twitch event.
- Fix: redeem alerts lost polaroid/art/emote since 4fda606 (they had ended up
  inside a comment), so sticker art, Power-up emotes and sound-only were gone.
- HUDFX embedded in the overlay with ?ext=hudfx (opt-in per OBS source): its
  page is served from our domain with the camcorder CSS, its settings API is
  forwarded, its Web Worker is started from a same-origin stand-in (the alert
  box needs it; blob: workers break the site CSP), and the box sits in the
  alert corner. The HUDFX URL is a field on the Settings page.
- Blerp cassette CSS kept with it (src/ext/blerp.css, pasted into the Blerp
  OBS source; Blerp itself cannot be embedded: its realtime server only
  accepts its own site).
- On-screen chat: Settings -> Hidden chatters and Hide ! commands.
- Outgoing raids are logged with a line in the server log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:29:20 +02:00
5f61b1ebe1 Overlay reloads itself after a deploy (boot ID), versioned asset URLs
OBS kept running the old alert scripts after a deploy, so TTS redeems fell
back to the cassette with no voice. The server now sends a boot ID on every
WebSocket connect; an overlay built with a different ID reloads itself.
Asset URLs carry ?v=<boot ID> so the reload never uses cached files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 15:22:44 +02:00
9e356b0875 TTS blocklist: starter list of slurs/TOS phrases, whole-word matching
- src/tts-blocklist.txt: slurs, self-harm/threat phrases, sexual violence,
  hate slogans (no normal swearing); merged into Settings once
  (tts_blocklist_seeded), editable there afterwards
- Matching is now whole words/phrases with plurals, look-alike swaps and
  spaced-out letters, so raccoon / spicy / therapist / grape are fine

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 15:09:12 +02:00
cf90b6be54 TTS: allow up to 500 characters, smaller handwriting on the letter for long messages
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 15:03:07 +02:00
50fd4b1cad tts setup: detect libespeak-ng by file, ldconfig is not on a user's PATH
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 14:45:26 +02:00
060b2351f7 TTS redeems: envelope letter with words inked in as spoken
- TTS alerts use the new `tts` style: envelope opens, the letter rises out
  and settles in front near the top, words ink in as the voice says them
  (timed from a loudness curve the server sends: tts.loudness, tts_env,
  tts_prefix); if the voice fails, the full text shows
- Highlight my message keeps its taped note

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 14:42:36 +02:00
4fda6060bf 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>
2026-11-21 14:34:41 +02:00
b5a81bdb15 Add TTS voice builder (/tts): Piper + espeak, layers, effects
- src/tts.js: synth(config, text) -> cached mp3 in public/tts; up to 3 layers
  (engine, voice, speaker, speed, pitch, volume, delay) mixed with ffmpeg,
  8 effects (stadium, echo, 8-bit, radio, robot, choir, warp, shaky), loudnorm;
  config is clamped and voice/speaker names are restricted to plain names
- tools/tts/worker.py: long-running Python worker (JSON lines), Piper models
  kept loaded (LRU of 4), espeak-ng via libespeak-ng + ctypes
- tools/tts/setup.sh: venv + piper-tts + default voice set
- /tts page: presets, layers, effects, test playback, save/load/delete named
  voices (tts_voices table); TTS link in the nav
- public/tts, tools/tts/venv and tools/tts/voices are gitignored

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 13:06:32 +02:00
463c6580f4 Chat: paper slips under the camera, Twitch + 7TV emotes
- public/chat/chat.css + chat.js (window.HSChat): cream paper slips with the
  name on a washi-tape label, newest on top sliding out from under the webcam,
  older ones glide down and fade at the bottom; message_timeout / max_messages
- Emotes: Twitch (tags.emotes) and 7TV global + channel sets (refreshed every
  10 min), zero-width 7TV emotes stack, emote-only messages get bigger emotes
- Deleted messages, timeouts, bans and /clear remove slips at once
- overlay.ejs: old chat CSS/JS removed, new files load only for ?parts=chat

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 12:08:12 +02:00
0cc53e1d73 Play the 250+ bits sound at half volume
TomDaTankLoud is much louder than the other alert sounds; the 250+ bits tier now
sets its own volume (0.4 instead of the default 0.8). Other tiers unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 23:30:48 +02:00
cdcd3737a7 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>
2026-11-20 23:18:15 +02:00
b28e56f991 Add StreamElements tips and a Feishin now-playing helper (disabled)
- src/streamelements.js: StreamElements Astro websocket, channel.tips with SE_JWT.
  Only allowed + successful tips alert, deduped by id, follows reconnect tokens.
  Off unless SE_JWT is set.
- tools/nowplaying/: PC helper that reads Feishin over MPRIS and posts title,
  artist and a small cover thumbnail to /nowplaying (Bearer NOWPLAYING_KEY). The
  cover is fetched on the LAN so the Navidrome token never leaves the PC.
  Endpoint and overlay widget are kept but switched off for now.
- .env.example: SE_JWT, NOWPLAYING_KEY.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 23:18:15 +02:00
553cc35b9e Add Redeems: channel points, built-in rewards and bits Power-ups
- reward_variations (src/db.js in the wiring commit): each trigger has variations,
  one is picked at random weighted by rarity (Common 50 / Uncommon 25 / Rare 12 /
  Ultra Rare 3), like Twitch alert variations.
- /redeems page: rewards listed live from Twitch, plus Power-ups and built-in
  rewards; per variation name, rarity (with % chance), sound + volume, show cassette
  or sound only, caption, sticker, on/off, play/test/two-click delete.
- Special styles: Gigantify -> giant emote, Celebration -> bouncing emotes,
  Highlight my message / Message Effect -> big taped note.
- redeems-seed.json: first-run defaults rebuilt from the Twitch alert setup
  (96 variations, 21 triggers); only loaded when the table is empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 23:18:15 +02:00
1766e37336 Overlay: cassette redeems, emote effects, poll card, Hype Train bar, raid card
New overlay modules (taped-paper look, shared with the polaroid alerts):
- cassette.js: redeems as a cassette tape; rarity = shell colour (Ultra Rare gold
  with glow, foil and sparkles), reels spin for the sound's length, sticker corner.
- fx.js: Gigantify (viewer's emote grows giant), On-Screen Celebration (emote
  copies bounce around the screen), highlight / Message Effect (tall taped note).
- poll.js: live poll card with bars, countdown and a WINNER stamp.
- hypebar.js: persistent Hype Train strip (level, progress, time left).
- raidcard.js: silent raid send-off card that stays during the raid countdown.
- nowplaying.js: Feishin now-playing slip (not loaded yet, see overlay).

polaroid.js: shared queue now also drives cassettes/effects; test alerts replace
only other tests and never cut off real alerts; alerts stay up for the animation
+ 3 s or the sound's length; sound lengths measured in the browser for UI-picked
sounds; tip and Hype Train alerts; optional ALERTS_BASE for offline test pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 23:18:15 +02:00
8c649c5bce Add redeem sounds and cut-out stickers
- public/alerts/sounds/redeems/: every channel point / Power-up / highlight clip,
  two-pass loudness-normalized to -16 LUFS (peaks <= -1.5 dBFS), so all redeems
  play at the same volume with the default 0.8. Originals stay in Nextcloud.
- public/alerts/sounds/: remaining library clips (a-rat, emotional damage for
  tips, okay-meme, ...) at their original level, next to the built-in alert sounds.
- public/alerts/stickers/: per-redeem cassette stickers, cut out with rembg or
  hand-drawn masks (soft fade where a photo edge cut the subject), plus a drawn
  chat bubble and the default headset Streamer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 23:18:15 +02:00
d481fc4f69 Add polaroid alerts for follows, subs, gifts, streaks, raids and bits
Overlay
- public/alerts/polaroid.js + .css: animated polaroid (photo drops in, tape
  and heart stick on, caption writes in), randomized angles, per-event art,
  caption, tape colour, badge and sound, fanned photo stack for multi-month
  subs / community gifts / raids, and a queue so alerts never overlap.
- Bits: no alert under 5; sound tiers at 5/50/75/100/150/250.
- Watch streaks are read from chat (USERNOTICE viewermilestone) and reported
  to the server over the overlay WebSocket.

Server
- Subscribe to channel.chat.notification instead of channel.subscribe /
  subscription.message / subscription.gift / channel.raid: one event with
  Prime, months bought at once, gift recipient, resub message and community
  gift totals. Per-recipient gift notices of a gift bomb are skipped, so a
  bomb is one alert (was N+1). Needs the user:read:chat scope (log in again).
- src/alerts.js maps Twitch events to alerts, broadcasts them and still runs
  them through dispatch (activity log + existing actions).
- EventSub starts on boot from the stored login (alerts survive restarts),
  validates the token hourly and refreshes it on expiry or 401, follows
  session_reconnect without dropping events, and reconnects when keepalives
  stop.
- The overlay WebSocket only accepts chat_notice messages from connections
  that pass the overlay UUID; streak notices are deduped by message id.

Dashboard
- Twitch connection status and a test button per alert (POST /alerts/test/:key).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 19:57:36 +02:00
88e906ff5d Tidy repo: rename vhost script, keep media folder
- `sh` -> `apache.sh` (it writes the Apache vhost for overlay.example.com)
- keep public/media/ in git via .gitkeep while ignoring uploads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 19:57:29 +02:00
9e0ddb8182 Update gitignore 2026-11-20 18:55:47 +01:00