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>
This commit is contained in:
parent
19a0965eb2
commit
b3caac7a31
11 changed files with 512 additions and 135 deletions
|
|
@ -31,6 +31,8 @@ const POWER_UPS = {
|
|||
gigantify_an_emote: 'Power-up: Gigantify an Emote',
|
||||
};
|
||||
|
||||
// Custom Power-ups (bits, made by the streamer on Twitch): kind 'custom_power_up', key = power-up id
|
||||
|
||||
// how a trigger is drawn on the overlay (everything else: cassette tape)
|
||||
const STYLE = {
|
||||
'power_up:gigantify_an_emote': 'emote', // the viewer's emote, giant
|
||||
|
|
@ -49,9 +51,10 @@ function pick(variations) {
|
|||
return pool[pool.length - 1] || null;
|
||||
}
|
||||
|
||||
function toAlert(v, { user, input, emote }) {
|
||||
function toAlert(v, { user, input, emote, bits }) {
|
||||
const spoken = !!(v.tts_voice_id && input); // TTS variations: envelope letter (fx.js envelope())
|
||||
const style = spoken ? 'tts' : (STYLE[`${v.kind}:${v.key}`] || 'cassette');
|
||||
// video variations play full-screen on the ?parts=video overlay (public/alerts/video.js)
|
||||
const style = v.video ? 'video' : spoken ? 'tts' : (STYLE[`${v.kind}:${v.key}`] || 'cassette');
|
||||
const line = spoken ? LINE.tts : LINE[style];
|
||||
return {
|
||||
type: 'redeem', kind: v.kind, key: v.key, style, vid: v.id, // vid: re-speak on replay if the mp3 was pruned
|
||||
|
|
@ -60,6 +63,7 @@ function toAlert(v, { user, input, emote }) {
|
|||
caption: style !== 'cassette' && v.caption === 'redeemed it! ♡' ? line : v.caption,
|
||||
sound: spoken ? null : (v.sound || null), volume: v.volume, // TTS on: the voice replaces the sound
|
||||
polaroid: !!v.polaroid, art: v.art || null, emote: emoteUrl(emote),
|
||||
video: v.video || null, bits: bits ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -90,10 +94,10 @@ async function addSpeech(v, alert) {
|
|||
}
|
||||
|
||||
// legacy action event type for the actions system / activity log
|
||||
const LEGACY = { reward: 'channel_points', auto_reward: 'auto_reward', power_up: 'power_up' };
|
||||
const LEGACY = { reward: 'channel_points', auto_reward: 'auto_reward', power_up: 'power_up', custom_power_up: 'custom_power_up' };
|
||||
|
||||
// A redemption arrived from Twitch.
|
||||
function handle(kind, key, title, { user, input, emote }, raw) {
|
||||
function handle(kind, key, title, { user, input, emote, bits }, raw) {
|
||||
if (title) db.renameTrigger(kind, key, title);
|
||||
const v = pick(db.getVariationsFor(kind, key));
|
||||
if (!v) {
|
||||
|
|
@ -101,19 +105,19 @@ function handle(kind, key, title, { user, input, emote }, raw) {
|
|||
dispatch.dispatchEvent(LEGACY[kind], key, user, raw);
|
||||
return null;
|
||||
}
|
||||
const alert = toAlert(v, { user, input, emote });
|
||||
if (v.tts_voice_id && input) addSpeech(v, alert).then(() => alerts.send(alert, raw)); // speech first, then the alert
|
||||
const alert = toAlert(v, { user, input, emote, bits });
|
||||
if (v.tts_voice_id && input && !v.video) addSpeech(v, alert).then(() => alerts.send(alert, raw)); // speech first, then the alert
|
||||
else alerts.send(alert, raw);
|
||||
return alert;
|
||||
}
|
||||
|
||||
// Dashboard Replay of an old activity row that has no stored alert: a fresh pick for the trigger,
|
||||
// with the viewer's original name and text. Resolves to the alert, or null if nothing is configured.
|
||||
async function rebuild(kind, key, { user, input, emote }) {
|
||||
async function rebuild(kind, key, { user, input, emote, bits }) {
|
||||
const v = pick(db.getVariationsFor(kind, key));
|
||||
if (!v) return null;
|
||||
const alert = toAlert(v, { user, input, emote });
|
||||
if (v.tts_voice_id && input) await addSpeech(v, alert);
|
||||
const alert = toAlert(v, { user, input, emote, bits });
|
||||
if (v.tts_voice_id && input && !v.video) await addSpeech(v, alert);
|
||||
return alert;
|
||||
}
|
||||
|
||||
|
|
@ -132,10 +136,11 @@ function test({ id, kind, key }) {
|
|||
const input = v.tts_voice_id ? 'Hydrate check! Also, nice shot, I was totally not camping that container.'
|
||||
: ['send_highlighted_message', 'message_effect'].includes(v.key) ? 'this is what a highlighted message looks like on stream!'
|
||||
: v.kind === 'reward' ? 'test input' : null;
|
||||
const alert = toAlert({ ...v, enabled: 1 }, { user: 'ChickenWhisperer', input, emote: v.kind === 'power_up' ? '25' : null }); // 25 = Kappa
|
||||
if (v.tts_voice_id) addSpeech(v, alert).then(() => alerts.sendTestAlert(alert));
|
||||
const alert = toAlert({ ...v, enabled: 1 }, { user: 'ChickenWhisperer', input, emote: v.kind === 'power_up' ? '25' : null,
|
||||
bits: v.kind === 'custom_power_up' ? 50 : null }); // 25 = Kappa
|
||||
if (v.tts_voice_id && !v.video) addSpeech(v, alert).then(() => alerts.sendTestAlert(alert));
|
||||
else alerts.sendTestAlert(alert);
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = { RARITY, AUTO_REWARDS, POWER_UPS, STYLE, pick, handle, test, rebuild, respeak };
|
||||
module.exports = { RARITY, AUTO_REWARDS, POWER_UPS, STYLE, LEGACY, pick, handle, test, rebuild, respeak };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue