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>
This commit is contained in:
parent
b28e56f991
commit
cdcd3737a7
17 changed files with 589 additions and 140 deletions
|
|
@ -7,7 +7,7 @@
|
|||
const { WebSocket } = require('ws');
|
||||
const twitch = require('./twitch');
|
||||
const alerts = require('./alerts');
|
||||
const dispatch = require('./dispatch');
|
||||
const redeems = require('./redeems');
|
||||
|
||||
const EVENTSUB_URL = 'wss://eventsub.wss.twitch.tv/ws';
|
||||
|
||||
|
|
@ -122,10 +122,23 @@ async function subscribeAll(sessionId) {
|
|||
const b = broadcasterId;
|
||||
const subs = [
|
||||
{ type: 'channel.follow', version: '2', condition: { broadcaster_user_id: b, moderator_user_id: b } },
|
||||
{ type: 'channel.cheer', version: '1', condition: { broadcaster_user_id: b } },
|
||||
// cheers AND bits Power-ups (message effect, celebration, gigantify); replaces channel.cheer
|
||||
{ type: 'channel.bits.use', version: '1', condition: { broadcaster_user_id: b } },
|
||||
// subs, resubs, gifts, community gifts, raids, with Prime/multi-month/recipient/message details
|
||||
{ type: 'channel.chat.notification', version: '1', condition: { broadcaster_user_id: b, user_id: b } },
|
||||
{ type: 'channel.channel_points_custom_reward_redemption.add', version: '1', condition: { broadcaster_user_id: b } },
|
||||
// built-in rewards: highlight message, unlock emote, ...
|
||||
{ type: 'channel.channel_points_automatic_reward_redemption.add', version: '2', condition: { broadcaster_user_id: b } },
|
||||
// live poll card on the overlay
|
||||
{ type: 'channel.poll.begin', version: '1', condition: { broadcaster_user_id: b } },
|
||||
{ type: 'channel.poll.progress', version: '1', condition: { broadcaster_user_id: b } },
|
||||
{ type: 'channel.poll.end', version: '1', condition: { broadcaster_user_id: b } },
|
||||
// outgoing raid: send-off card (incoming raids come through channel.chat.notification)
|
||||
{ type: 'channel.raid', version: '1', condition: { from_broadcaster_user_id: b } },
|
||||
// Hype Train alerts (start, level up, end)
|
||||
{ type: 'channel.hype_train.begin', version: '2', condition: { broadcaster_user_id: b } },
|
||||
{ type: 'channel.hype_train.progress', version: '2', condition: { broadcaster_user_id: b } },
|
||||
{ type: 'channel.hype_train.end', version: '2', condition: { broadcaster_user_id: b } },
|
||||
];
|
||||
|
||||
try { await twitch.validate(); } catch (e) { console.error('[eventsub]', e.message); }
|
||||
|
|
@ -161,8 +174,14 @@ function handleNotification(payload) {
|
|||
case 'channel.follow':
|
||||
alerts.send(alerts.fromFollow(event), event);
|
||||
break;
|
||||
case 'channel.cheer':
|
||||
alerts.send(alerts.fromCheer(event), event);
|
||||
case 'channel.bits.use':
|
||||
if (event.type === 'power_up' && event.power_up?.type) {
|
||||
const t = event.power_up.type;
|
||||
redeems.handle('power_up', t, redeems.POWER_UPS[t] || `Power-up: ${t}`,
|
||||
{ user: event.user_name || event.user_login, input: event.message?.text || null, emote: event.power_up.emote?.id }, event);
|
||||
} else {
|
||||
alerts.send(alerts.fromBitsUse(event), event);
|
||||
}
|
||||
break;
|
||||
case 'channel.chat.notification': {
|
||||
const alert = alerts.fromChatNotification(event);
|
||||
|
|
@ -171,9 +190,32 @@ function handleNotification(payload) {
|
|||
break;
|
||||
}
|
||||
case 'channel.channel_points_custom_reward_redemption.add':
|
||||
// no polaroid alert yet; existing actions still fire
|
||||
dispatch.dispatchEvent('channel_points', event.reward?.id, event.user_name || event.user_login, event);
|
||||
redeems.handle('reward', event.reward.id, event.reward.title,
|
||||
{ user: event.user_name || event.user_login, input: event.user_input || null }, event);
|
||||
break;
|
||||
case 'channel.poll.begin':
|
||||
case 'channel.poll.progress':
|
||||
case 'channel.poll.end':
|
||||
alerts.sendPoll(type.split('.').pop(), event);
|
||||
break;
|
||||
case 'channel.hype_train.begin':
|
||||
case 'channel.hype_train.progress':
|
||||
case 'channel.hype_train.end': {
|
||||
const phase = type.split('.').pop();
|
||||
alerts.sendHypeBar(phase, event); // persistent progress bar
|
||||
const alert = alerts.fromHypeTrain(phase, event); // queued alert on start / new level / end
|
||||
if (alert) alerts.send(alert, event);
|
||||
break;
|
||||
}
|
||||
case 'channel.raid':
|
||||
if (event.from_broadcaster_user_id === broadcasterId) alerts.raidHappened(event).catch(e => console.error('[alerts] raid out:', e.message));
|
||||
break;
|
||||
case 'channel.channel_points_automatic_reward_redemption.add': {
|
||||
const t = event.reward?.type;
|
||||
redeems.handle('auto_reward', t, redeems.AUTO_REWARDS[t] || t,
|
||||
{ user: event.user_name || event.user_login, input: event.message?.text || null, emote: event.reward?.emote?.id }, event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue