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>
This commit is contained in:
parent
a7a701a678
commit
2991c88d9e
2 changed files with 20 additions and 6 deletions
|
|
@ -9,9 +9,9 @@ everyone's points recalculate. Name to be decided (e.g. "Streamer points").
|
||||||
|
|
||||||
| Action | Points | Notes |
|
| Action | Points | Notes |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Chat message | 10 | capped per viewer (1/min, 1 per 2 min or 1 per 5 min: to decide); needs a points-eligible counter at ingestion |
|
| Chat message | 10 | max 1 per 5 min per viewer (counted at ingestion: chat_user.scored / chat_user_day.scored) |
|
||||||
| First message in a stream (check-in) | 25 | once per stream |
|
| First message in a stream (check-in) | 25 | once per stream; needs stream.online/offline to know streams |
|
||||||
| First message ever on the channel | 50 | |
|
| First message ever on the channel | 50 | Twitch's first-time chatter flag, kept in chat_user.intro |
|
||||||
| Follow | 50 | once |
|
| Follow | 50 | once |
|
||||||
| Watch streak | 5 x streak | max 100 |
|
| Watch streak | 5 x streak | max 100 |
|
||||||
| Channel point redeem | 1 per 100 points spent | |
|
| Channel point redeem | 1 per 100 points spent | |
|
||||||
|
|
@ -22,9 +22,10 @@ everyone's points recalculate. Name to be decided (e.g. "Streamer points").
|
||||||
| Tip | 100 per 1 EUR | |
|
| Tip | 100 per 1 EUR | |
|
||||||
| Incoming raid | 100 flat | no reward for raid size |
|
| Incoming raid | 100 flat | no reward for raid size |
|
||||||
| Emotes, commands | 0 | stats only, no farming |
|
| Emotes, commands | 0 | stats only, no farming |
|
||||||
| Watch time | 5-15 per 10 min live (to decide; suggested 10 with chat cap 1 per 2 min) | needs moderator:read:chatters (chatter list) |
|
| Watch time | 10 per 10 min live | needs moderator:read:chatters (chatter list) |
|
||||||
|
|
||||||
Levels (cassette theme): Newcomer, Regular 500, Tape Collector 2000, Mixtape Maker 6000, Side B Legend 15000.
|
Levels (cassette theme): Newcomer, Regular 500, Tape Collector 2000, Mixtape Maker 6000, Side B Legend 15000.
|
||||||
|
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).
|
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).
|
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 (her decision 2026-11-22: records of support, like Twitch keeps); forget-a-viewer removes theirs.
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
const db = require('./db');
|
const db = require('./db');
|
||||||
|
|
||||||
const RAW_DAYS = 30;
|
const RAW_DAYS = 30;
|
||||||
|
const SCORE_GAP_MS = 5 * 60 * 1000; // point system: a message earns points only 5 min after the viewer's last one that did
|
||||||
let ready = false;
|
let ready = false;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
@ -59,6 +60,13 @@ function init() {
|
||||||
PRIMARY KEY (user_id, command)
|
PRIMARY KEY (user_id, command)
|
||||||
);
|
);
|
||||||
`);
|
`);
|
||||||
|
// point-system columns (added after the first version): points-eligible messages, first-ever-message flag
|
||||||
|
const cols = db.raw().prepare('PRAGMA table_info(chat_user)').all().map(c => c.name);
|
||||||
|
for (const [c, def] of [['scored', 'INTEGER DEFAULT 0'], ['last_scored', 'TEXT'], ['intro', 'INTEGER DEFAULT 0']]) {
|
||||||
|
if (!cols.includes(c)) db.raw().exec(`ALTER TABLE chat_user ADD COLUMN ${c} ${def}`);
|
||||||
|
}
|
||||||
|
const dcols = db.raw().prepare('PRAGMA table_info(chat_user_day)').all().map(c => c.name);
|
||||||
|
if (!dcols.includes('scored')) db.raw().exec('ALTER TABLE chat_user_day ADD COLUMN scored INTEGER DEFAULT 0');
|
||||||
ready = true;
|
ready = true;
|
||||||
setInterval(prune, 60 * 60 * 1000).unref();
|
setInterval(prune, 60 * 60 * 1000).unref();
|
||||||
prune();
|
prune();
|
||||||
|
|
@ -108,8 +116,13 @@ function onMessage(e) {
|
||||||
ON CONFLICT(user_id) DO UPDATE SET messages = messages + 1, user_login = excluded.user_login,
|
ON CONFLICT(user_id) DO UPDATE SET messages = messages + 1, user_login = excluded.user_login,
|
||||||
user_name = excluded.user_name, last_seen = excluded.last_seen`)
|
user_name = excluded.user_name, last_seen = excluded.last_seen`)
|
||||||
.run(e.chatter_user_id, login, e.chatter_user_name || login, at, at);
|
.run(e.chatter_user_id, login, e.chatter_user_name || login, at, at);
|
||||||
d.prepare(`INSERT INTO chat_user_day (user_id, day, messages) VALUES (?, ?, 1)
|
// points-eligible: at least SCORE_GAP_MS since this viewer's last eligible message
|
||||||
ON CONFLICT(user_id, day) DO UPDATE SET messages = messages + 1`).run(e.chatter_user_id, day);
|
const prev = d.prepare('SELECT last_scored FROM chat_user WHERE user_id = ?').get(e.chatter_user_id);
|
||||||
|
const scored = !prev?.last_scored || Date.parse(at) - Date.parse(prev.last_scored) >= SCORE_GAP_MS ? 1 : 0;
|
||||||
|
if (scored) d.prepare('UPDATE chat_user SET scored = scored + 1, last_scored = ? WHERE user_id = ?').run(at, e.chatter_user_id);
|
||||||
|
if (e.message_type === 'user_intro') d.prepare('UPDATE chat_user SET intro = 1 WHERE user_id = ?').run(e.chatter_user_id);
|
||||||
|
d.prepare(`INSERT INTO chat_user_day (user_id, day, messages, scored) VALUES (?, ?, 1, ?)
|
||||||
|
ON CONFLICT(user_id, day) DO UPDATE SET messages = messages + 1, scored = scored + excluded.scored`).run(e.chatter_user_id, day, scored);
|
||||||
const em = d.prepare(`INSERT INTO chat_emote (user_id, emote, source, emote_id, uses, last_used) VALUES (?, ?, ?, ?, 1, ?)
|
const em = d.prepare(`INSERT INTO chat_emote (user_id, emote, source, emote_id, uses, last_used) VALUES (?, ?, ?, ?, 1, ?)
|
||||||
ON CONFLICT(user_id, emote) DO UPDATE SET uses = uses + 1, last_used = excluded.last_used`);
|
ON CONFLICT(user_id, emote) DO UPDATE SET uses = uses + 1, last_used = excluded.last_used`);
|
||||||
for (const x of emotes) em.run(e.chatter_user_id, x.name, x.source, x.id, at);
|
for (const x of emotes) em.run(e.chatter_user_id, x.name, x.source, x.id, at);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue