Added support for Twitch Watch Streaks

This commit is contained in:
nuttylmao
2025-11-08 05:43:49 +11:00
parent fff3e5d020
commit 38cd241122
6 changed files with 129 additions and 0 deletions
+47
View File
@@ -51,6 +51,7 @@ const showTwitchFollows = GetBooleanParam("showTwitchFollows", false);
const showTwitchSubs = GetBooleanParam("showTwitchSubs", true);
const showTwitchChannelPointRedemptions = GetBooleanParam("showTwitchChannelPointRedemptions", true);
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true);
const showTwitchSharedChat = GetIntParam("showTwitchSharedChat", 2);
const kickUsername = urlParams.get("kickUsername") || "";
@@ -200,6 +201,11 @@ client.on('Twitch.Raid', (response) => {
TwitchRaid(response.data);
})
client.on('Twitch.WatchStreak', (response) => {
console.debug(response.data);
TwitchWatchStreak(response.data);
})
client.on('Twitch.ChatMessageDeleted', (response) => {
console.debug(response.data);
TwitchChatMessageDeleted(response.data);
@@ -1160,6 +1166,47 @@ async function TwitchRaid(data) {
AddMessageItem(instance, data.messageId);
}
async function TwitchWatchStreak(data) {
if (!showTwitchWatchStreaks)
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.userName;
const avatarURL = await GetAvatar(username, 'twitch');
const avatar = new Image();
avatar.src = avatarURL;
avatar.classList.add("avatar");
avatarDiv.appendChild(avatar);
}
const displayName = data.displayName;
const watchStreak = data.watchStreak;
const message = data.message;
titleDiv.innerText = `${displayName} is currently on a ${watchStreak}-stream streak! `;
contentDiv.innerText = `${message}`;
AddMessageItem(instance, data.messageId);
}
function TwitchChatMessageDeleted(data) {
const messageList = document.getElementById("messageList");
+8
View File
@@ -282,6 +282,14 @@
"defaultValue": true,
"group": "Which Twitch messages do you want to see?"
},
{
"id": "showTwitchWatchStreaks",
"label": "Watch Streaks",
"description": "",
"type": "checkbox",
"defaultValue": true,
"group": "Which Twitch messages do you want to see?"
},
{
"id": "showTwitchSharedChat",
"label": "Shared Chat Messages",