Added support for Twitch Power Ups

This commit is contained in:
nutty
2026-05-10 21:44:34 +10:00
parent e4761eae79
commit f92ffcc5da
9 changed files with 164 additions and 0 deletions
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 2664 2665" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(1.03455,0,0,1.03455,-46.020186,0)">
<path d="M1332,0L2444,1578L1332,2576L220,1578L1332,0ZM1332,1778L1922,1519L1332,622L742,1519L1332,1778Z" style="fill:white;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 658 B

+23
View File
@@ -46,6 +46,7 @@ const showTwitchAnnouncements = GetBooleanParam("showTwitchAnnouncements", true)
const showTwitchFollows = GetBooleanParam("showTwitchFollows", false); const showTwitchFollows = GetBooleanParam("showTwitchFollows", false);
const showTwitchSubs = GetBooleanParam("showTwitchSubs", true); const showTwitchSubs = GetBooleanParam("showTwitchSubs", true);
const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPointRedemptions", true); const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPointRedemptions", true);
const showTwitchPowerUpRedemptions = GetBooleanParam("showTwitchPowerUpRedemptions", true);
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true); const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true); const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true);
const showTwitchSharedChat = GetBooleanParam("showTwitchSharedChat", true); const showTwitchSharedChat = GetBooleanParam("showTwitchSharedChat", true);
@@ -181,6 +182,11 @@ client.on('Twitch.RewardRedemption', (response) => {
TwitchRewardRedemption(response.data); TwitchRewardRedemption(response.data);
}) })
client.on('Twitch.CustomPowerUpRedemption', (response) => {
console.debug(response.data);
TwitchCustomPowerUpRedemption(response.data);
})
client.on('Twitch.Raid', (response) => { client.on('Twitch.Raid', (response) => {
console.debug(response.data); console.debug(response.data);
TwitchRaid(response.data); TwitchRaid(response.data);
@@ -788,6 +794,23 @@ async function TwitchRewardRedemption(data) {
ShowAlert(message, 'twitch'); ShowAlert(message, 'twitch');
} }
async function TwitchCustomPowerUpRedemption(data) {
if (!showTwitchPowerUpRedemptions)
return;
let username = data.user.name;
if (data.user.name.toLowerCase() != data.user.login.toLowerCase())
username = `${data.user.name} (${data.user.login})`;
const powerUpName = data.custom_power_up.title;
const cost = data.custom_power_up.bits_cost;
const prompt = data.custom_power_up.prompt;
const bitIcon = `<img src="icons/badges/twitch-bit.svg" class="platform"/>`;
let message = `${username} redeemed ${powerUpName} ${bitIcon} ${cost}`;
ShowAlert(message, 'twitch');
}
async function TwitchRaid(data) { async function TwitchRaid(data) {
if (!showTwitchRaids) if (!showTwitchRaids)
return; return;
+8
View File
@@ -175,6 +175,14 @@
"defaultValue": true, "defaultValue": true,
"group": "Which Twitch messages do you want to see?" "group": "Which Twitch messages do you want to see?"
}, },
{
"id": "showTwitchPowerUpRedemptions",
"label": "Power-Up Redemptions",
"description": "",
"type": "checkbox",
"defaultValue": true,
"group": "Which Twitch messages do you want to see?"
},
{ {
"id": "showTwitchRaids", "id": "showTwitchRaids",
"label": "Raids", "label": "Raids",
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 2664 2665" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(1.03455,0,0,1.03455,-46.020186,0)">
<path d="M1332,0L2444,1578L1332,2576L220,1578L1332,0ZM1332,1778L1922,1519L1332,622L742,1519L1332,1778Z" style="fill:white;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 658 B

+52
View File
@@ -52,6 +52,7 @@ const showTwitchAnnouncements = GetBooleanParam("showTwitchAnnouncements", true)
const showTwitchFollows = GetBooleanParam("showTwitchFollows", false); const showTwitchFollows = GetBooleanParam("showTwitchFollows", false);
const showTwitchSubs = GetBooleanParam("showTwitchSubs", true); const showTwitchSubs = GetBooleanParam("showTwitchSubs", true);
const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPointRedemptions", true); const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPointRedemptions", true);
const showTwitchPowerUpRedemptions = GetBooleanParam("showTwitchPowerUpRedemptions", true);
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true); const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true); const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true);
const showTwitchSharedChat = GetIntParam("showTwitchSharedChat", 2); const showTwitchSharedChat = GetIntParam("showTwitchSharedChat", 2);
@@ -202,6 +203,11 @@ client.on('Twitch.RewardRedemption', (response) => {
TwitchRewardRedemption(response.data); TwitchRewardRedemption(response.data);
}) })
client.on('Twitch.CustomPowerUpRedemption', (response) => {
console.debug(response.data);
TwitchCustomPowerUpRedemption(response.data);
})
client.on('Twitch.Raid', (response) => { client.on('Twitch.Raid', (response) => {
console.debug(response.data); console.debug(response.data);
TwitchRaid(response.data); TwitchRaid(response.data);
@@ -1170,6 +1176,52 @@ async function TwitchRewardRedemption(data) {
AddMessageItem(instance, data.messageId); AddMessageItem(instance, data.messageId);
} }
async function TwitchCustomPowerUpRedemption(data) {
if (!showTwitchPowerUpRedemptions)
return;
// Get a reference to the template
const template = document.getElementById('cardTemplate');
// Create a new instance of the template
const instance = template.content.cloneNode(true);
// Get divs
const cardDiv = instance.querySelector("#card");
const headerDiv = instance.querySelector("#header");
const avatarDiv = instance.querySelector("#avatar");
const iconDiv = instance.querySelector("#icon");
const titleDiv = instance.querySelector("#title");
const contentDiv = instance.querySelector("#content");
// Set the card background colors
cardDiv.classList.add('twitch');
if (showAvatar) {
// Render avatars
const username = data.user.login;
const avatarURL = await GetAvatar(username, 'twitch');
const avatar = new Image();
avatar.src = avatarURL;
avatar.classList.add("avatar");
avatarDiv.appendChild(avatar);
}
// Set the text
let username = data.user.name;
if (data.user.name.toLowerCase() != data.user.login.toLowerCase())
username = `${data.user.name} (${data.user.login})`;
const powerUpName = data.custom_power_up.title;
const cost = data.custom_power_up.bits_cost;
const prompt = data.custom_power_up.prompt;
const bitIcon = `<img src="icons/badges/twitch-bit.svg" class="platform"/>`;
titleDiv.innerHTML = `${username} redeemed ${powerUpName} ${bitIcon} ${cost}`;
contentDiv.innerText = `${prompt}`;
AddMessageItem(instance, data.messageId);
}
async function TwitchRaid(data) { async function TwitchRaid(data) {
if (!showTwitchRaids) if (!showTwitchRaids)
return; return;
+8
View File
@@ -290,6 +290,14 @@
"defaultValue": true, "defaultValue": true,
"group": "Which Twitch messages do you want to see?" "group": "Which Twitch messages do you want to see?"
}, },
{
"id": "showTwitchPowerUpRedemptions",
"label": "Power-Up Redemptions",
"description": "",
"type": "checkbox",
"defaultValue": true,
"group": "Which Twitch messages do you want to see?"
},
{ {
"id": "showTwitchRaids", "id": "showTwitchRaids",
"label": "Raids", "label": "Raids",
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 2664 2665" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(1.03455,0,0,1.03455,-46.020186,0)">
<path d="M1332,0L2444,1578L1332,2576L220,1578L1332,0ZM1332,1778L1922,1519L1332,622L742,1519L1332,1778Z" style="fill:white;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 658 B

+35
View File
@@ -63,6 +63,8 @@ const showTwitchSubs = GetBooleanParam("showTwitchSubs", true);
const twitchSubAction = urlParams.get("twitchSubAction") || ""; const twitchSubAction = urlParams.get("twitchSubAction") || "";
const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPointRedemptions", true); const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPointRedemptions", true);
const twitchChannelPointRedemptionAction = urlParams.get("twitchChannelPointRedemptionAction") || ""; const twitchChannelPointRedemptionAction = urlParams.get("twitchChannelPointRedemptionAction") || "";
const showTwitchPowerUpRedemptions = GetBooleanParam("showTwitchPowerUpRedemptions", true);
const twitchPowerUpRedemptionAction = urlParams.get("twitchPowerUpRedemptionAction") || "";
const showTwitchCheers = GetBooleanParam("showTwitchCheers", true); const showTwitchCheers = GetBooleanParam("showTwitchCheers", true);
const twitchCheerAction = urlParams.get("twitchCheerAction") || ""; const twitchCheerAction = urlParams.get("twitchCheerAction") || "";
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true); const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
@@ -218,6 +220,11 @@ client.on('Twitch.RewardRedemption', (response) => {
TwitchRewardRedemption(response.data); TwitchRewardRedemption(response.data);
}) })
client.on('Twitch.CustomPowerUpRedemption', (response) => {
console.debug(response.data);
TwitchCustomPowerUpRedemption(response.data);
})
client.on('Twitch.Raid', (response) => { client.on('Twitch.Raid', (response) => {
console.debug(response.data); console.debug(response.data);
TwitchRaid(response.data); TwitchRaid(response.data);
@@ -696,6 +703,34 @@ async function TwitchRewardRedemption(data) {
); );
} }
async function TwitchCustomPowerUpRedemption(data) {
if (!showTwitchPowerUpRedemptions)
return;
let username = data.user.name;
if (data.user.name.toLowerCase() != data.user.login.toLowerCase())
username = `${data.user.name} (${data.user.login})`;
const powerUpName = data.custom_power_up.title;
const cost = data.custom_power_up.bits_cost;
const prompt = data.custom_power_up.prompt;
const bitIcon = `<img src="icons/badges/twitch-bit.svg" class="platform" style="height: 1em"/>`;
// Render avatars
const avatarURL = await GetAvatar(data.user.login, 'twitch');
UpdateAlertBox(
'twitch',
avatarURL,
`${username} redeemed`,
`${powerUpName} ${bitIcon} ${cost}`,
'',
username,
prompt,
twitchPowerUpRedemptionAction,
data
);
}
async function TwitchRaid(data) { async function TwitchRaid(data) {
if (!showTwitchRaids) if (!showTwitchRaids)
return; return;
+17
View File
@@ -278,6 +278,23 @@
"showIf": "showTwitchChannelPointRedemptions", "showIf": "showTwitchChannelPointRedemptions",
"group": "Which Twitch alerts do you want to see?" "group": "Which Twitch alerts do you want to see?"
}, },
{
"id": "showTwitchPowerUpRedemptions",
"label": "Power-Up Redemptions",
"description": "",
"type": "checkbox",
"defaultValue": true,
"group": "Which Twitch alerts do you want to see?"
},
{
"id": "twitchPowerUpRedemptionAction",
"label": "",
"description": "Also run this Streamer.bot Action",
"type": "sb-actions",
"defaultValue": "",
"showIf": "showTwitchPowerUpRedemptions",
"group": "Which Twitch alerts do you want to see?"
},
{ {
"id": "showTwitchCheers", "id": "showTwitchCheers",
"label": "Cheers", "label": "Cheers",