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>
This commit is contained in:
Bashy 2026-11-23 11:22:49 +02:00
parent 5bf4bffaa0
commit c481ca92cb
57 changed files with 3080 additions and 774 deletions

View file

@ -5,7 +5,7 @@ Ideas agreed on but not built yet. Newest first. (Started 2026-11-22.)
## 4. Point system (draft, 2026-11-22)
Loyalty points calculated from the per-viewer statistics (src/chatlog.js), so values can change later and
everyone's points recalculate. Name to be decided (e.g. "Streamer points").
everyone's points recalculate. Name to be decided (e.g. "<channel> points").
| Action | Points | Notes |
|---|---|---|
@ -24,12 +24,12 @@ everyone's points recalculate. Name to be decided (e.g. "Streamer points").
| Emotes, commands | 0 | stats only, no farming |
| Watch time | 5 per 5 min live (one tick updates watch time and points together; built: src/watchtime.js) | needs moderator:read:chatters (chatter list); import StreamElements' watch time once (SE key already in .env) so viewers keep their history when our bot takes over `!watchtime` |
Levels by watch time (ours + StreamElements import), her choice 2026-11-22: Viewer, Regular (50 h), Loyal (200 h), Veteran (1000 h).
Levels by watch time (ours + StreamElements import), decided: Viewer, Regular (50 h), Loyal (200 h), Veteran (1000 h).
Points only rank the leaderboard; bits/subs do not buy a level.
Balance: lurker 60/h, active chatter up to 180/h; Tier 1 sub (500) ~ 8 h watching.
Uses: `!points`, on-stream leaderboard, level next to names in the overlay chat, spending on free Power-up uses (1).
Rule: points earned from bits must never be exchanged for things with money value (Bits Acceptable Use Policy).
Activity log stays (her decision 2026-11-22: records of support, like Twitch keeps); forget-a-viewer removes theirs.
Activity log stays (decided: records of support, like Twitch keeps); forget-a-viewer removes theirs.
## 1. Free uses of Custom Power-ups ("refund")
@ -53,7 +53,7 @@ Estimate: about half a day once chat is read server-side.
**Why:** one place for alerts, redeems, commands and replies; no third-party bot.
**Rough shape**
- Bot account: `bot_account` logs in to HeyStreamer once (Twitch scopes `user:read:chat`, `user:write:chat`;
- Bot account: the channel's own bot account logs in to HeyStreamer once (Twitch scopes `user:read:chat`, `user:write:chat`;
the bot also needs to be a mod/VIP in the channel for reliable sending).
- Reads chat via EventSub `channel.chat.message`, sends via Helix `POST /chat/messages`.
- Commands page: custom text commands (`!discord`, `!socials`, …) with cooldowns and permission levels
@ -75,9 +75,32 @@ Estimate: about half a day once chat is read server-side.
for stream statistics.
- Size: a few MB per month in SQLite.
Status: **logging built 2026-11-22** (src/chatlog.js), with her choices: per-viewer counts (messages, per day,
Status: **logging built 2026-11-22** (src/chatlog.js), with these choices: per-viewer counts (messages, per day,
emotes incl. 7TV, !commands, first/last seen) parsed as messages arrive; raw messages kept **30 days** only;
moderation removes stored text; hidden chatters (bots) are counted but must be left out of shown
statistics and leaderboards (filter at display time with chatlog.isHidden()). Viewer actions are counted too
(chat_action: rewards + points, Power-ups + bits, cheers, subs, gifts, follows, raids, watch streaks, tips). Still to do: a statistics page, and a
"forget this viewer" button for removal requests (`chatlog.forgetUser()` exists).
**2026-11-23: per-stream and period statistics + public page.** `src/periodstats.js` keeps one generic table,
`stat_day` (day x stream x viewer x kind x item), fed by chatlog.js (messages, first messages, emotes, commands,
actions) and watchtime.js (watch ticks); backfilled once from the older tables. A new statistic = a new `kind`,
then a section in `views/_statsbody.ejs` (shared by the admin Stats page and the public page). Streams keep title,
game, peak + average viewers. Public page: Settings → Public stats page (its own host name; on that
host nothing else answers; `/public` on the admin host is a preview). It never shows message text, bots, the
streamer on leaderboards, or viewers who typed `!hideme` (`!showme` undoes it; also a button on the viewer page).
The StreamElements watch-time importer is removed; the minutes imported on 2026-11-22 stay as a fixed baseline
(watch_import: All time, points, levels).
**2026-11-23 (2): data from Twitch** (`src/twitchsync.js`, every 6 h, after each stream, "Sync with Twitch" button):
followers with follow dates (whole history), current subs, mods (`moderation:read`), VIPs (`channel:read:vips`; both
scopes need one new login), all-time bits top 100, the channel's emotes, past streams from VODs (7/60 days only).
Per stream: viewer count every 5 min (`stream_viewers`) and every title/category change (`stream_change`, EventSub
`channel.update`). Not on Twitch's API at all: past viewer counts, past titles, emote use outside this channel.
The old /actions page (event → sound rules, unused) is gone; "Actions" is now the nav group Redeems / TTS / Media.
**2026-11-23 (3): Twitch analytics CSV** (`src/twitchcsv.js`, Stats → "Import Twitch analytics (CSV)"): the Creator
Dashboard export "Analytics and Revenue by day". No API offers this: export by hand now and then and import again (per day, safe).
Before the cutoff (first day HeyStreamer counted) it supplies messages, watch time, follows, streamed days/hours;
for every day it supplies what only Twitch measures (unique / engaged viewers, clips, live views, average + peak
viewers, revenue). Revenue: admin page only, never public.