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>
This commit is contained in:
Bashy 2026-11-22 17:21:34 +02:00
parent 30f42a65e8
commit cd751e3a07
5 changed files with 156 additions and 2 deletions

View file

@ -41,9 +41,12 @@ Estimate: about half a day once chat is read server-side.
- Store only: message id, time, user id + login + display name, text, badges, emotes, first-message / reply flags.
- Honour moderation: `channel.chat.message_delete`, `channel.chat.clear_user_messages` (timeouts/bans) and
`channel.chat.clear` remove or blank the stored messages.
- Retention: raw messages 12 months (then deleted), aggregated statistics kept.
- Retention: raw messages 30 days (then deleted), aggregated statistics kept.
- "Delete this user's messages" control for removal requests; a line in the Twitch panels that chat is logged
for stream statistics.
- Size: a few MB per month in SQLite.
Status: proposed 2026-11-22, waiting for her OK on the defaults above before logging starts.
Status: **logging built 2026-11-22** (src/chatlog.js), with her 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) not counted. Still to do: a statistics page, and a
"forget this viewer" button for removal requests (`chatlog.forgetUser()` exists).