mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-19 04:00:59 -04:00
Added support for Twitch Watch Streaks
This commit is contained in:
@@ -46,6 +46,7 @@ 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 showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
|
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
|
||||||
|
const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true);
|
||||||
const showTwitchSharedChat = GetBooleanParam("showTwitchSharedChat", true);
|
const showTwitchSharedChat = GetBooleanParam("showTwitchSharedChat", true);
|
||||||
|
|
||||||
const kickUsername = urlParams.get("kickUsername") || "";
|
const kickUsername = urlParams.get("kickUsername") || "";
|
||||||
@@ -181,6 +182,11 @@ client.on('Twitch.Raid', (response) => {
|
|||||||
TwitchRaid(response.data);
|
TwitchRaid(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
client.on('Twitch.WatchStreak', (response) => {
|
||||||
|
console.debug(response.data);
|
||||||
|
TwitchWatchStreak(response.data);
|
||||||
|
})
|
||||||
|
|
||||||
client.on('Twitch.ChatMessageDeleted', (response) => {
|
client.on('Twitch.ChatMessageDeleted', (response) => {
|
||||||
console.debug(response.data);
|
console.debug(response.data);
|
||||||
TwitchChatMessageDeleted(response.data);
|
TwitchChatMessageDeleted(response.data);
|
||||||
@@ -789,6 +795,18 @@ async function TwitchRaid(data) {
|
|||||||
ShowAlert(message, 'twitch');
|
ShowAlert(message, 'twitch');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function TwitchWatchStreak(data) {
|
||||||
|
if (!showTwitchWatchStreaks)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const displayName = data.displayName;
|
||||||
|
const watchStreak = data.watchStreak;
|
||||||
|
|
||||||
|
let message = `${displayName} is currently on a ${watchStreak}-stream streak!`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'twitch');
|
||||||
|
}
|
||||||
|
|
||||||
function TwitchChatMessageDeleted(data) {
|
function TwitchChatMessageDeleted(data) {
|
||||||
const messageList = document.getElementById("messageList");
|
const messageList = document.getElementById("messageList");
|
||||||
|
|
||||||
|
|||||||
@@ -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": "showTwitchWatchStreaks",
|
||||||
|
"label": "Watch Streaks",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": true,
|
||||||
|
"group": "Which Twitch messages do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "showTwitchSharedChat",
|
"id": "showTwitchSharedChat",
|
||||||
"label": "Shared Chat Messages",
|
"label": "Shared Chat Messages",
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ 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 showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
|
const showTwitchRaids = GetBooleanParam("showTwitchRaids", true);
|
||||||
|
const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true);
|
||||||
const showTwitchSharedChat = GetIntParam("showTwitchSharedChat", 2);
|
const showTwitchSharedChat = GetIntParam("showTwitchSharedChat", 2);
|
||||||
|
|
||||||
const kickUsername = urlParams.get("kickUsername") || "";
|
const kickUsername = urlParams.get("kickUsername") || "";
|
||||||
@@ -200,6 +201,11 @@ client.on('Twitch.Raid', (response) => {
|
|||||||
TwitchRaid(response.data);
|
TwitchRaid(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
client.on('Twitch.WatchStreak', (response) => {
|
||||||
|
console.debug(response.data);
|
||||||
|
TwitchWatchStreak(response.data);
|
||||||
|
})
|
||||||
|
|
||||||
client.on('Twitch.ChatMessageDeleted', (response) => {
|
client.on('Twitch.ChatMessageDeleted', (response) => {
|
||||||
console.debug(response.data);
|
console.debug(response.data);
|
||||||
TwitchChatMessageDeleted(response.data);
|
TwitchChatMessageDeleted(response.data);
|
||||||
@@ -1160,6 +1166,47 @@ async function TwitchRaid(data) {
|
|||||||
AddMessageItem(instance, data.messageId);
|
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) {
|
function TwitchChatMessageDeleted(data) {
|
||||||
const messageList = document.getElementById("messageList");
|
const messageList = document.getElementById("messageList");
|
||||||
|
|
||||||
|
|||||||
@@ -282,6 +282,14 @@
|
|||||||
"defaultValue": true,
|
"defaultValue": true,
|
||||||
"group": "Which Twitch messages do you want to see?"
|
"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",
|
"id": "showTwitchSharedChat",
|
||||||
"label": "Shared Chat Messages",
|
"label": "Shared Chat Messages",
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ 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);
|
||||||
const twitchRaidAction = urlParams.get("twitchRaidAction") || "";
|
const twitchRaidAction = urlParams.get("twitchRaidAction") || "";
|
||||||
|
const showTwitchWatchStreaks = GetBooleanParam("showTwitchWatchStreaks", true);
|
||||||
|
const twitchWatchStreaksAction = urlParams.get("twitchWatchStreaksAction") || "";
|
||||||
|
|
||||||
// Which Kick alerts do you want to see?
|
// Which Kick alerts do you want to see?
|
||||||
const kickUsername = urlParams.get("kickUsername") || "";
|
const kickUsername = urlParams.get("kickUsername") || "";
|
||||||
@@ -211,6 +213,11 @@ client.on('Twitch.Raid', (response) => {
|
|||||||
TwitchRaid(response.data);
|
TwitchRaid(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
client.on('Twitch.WatchStreak', (response) => {
|
||||||
|
console.debug(response.data);
|
||||||
|
TwitchWatchStreak(response.data);
|
||||||
|
})
|
||||||
|
|
||||||
client.on('YouTube.SuperChat', (response) => {
|
client.on('YouTube.SuperChat', (response) => {
|
||||||
console.debug(response.data);
|
console.debug(response.data);
|
||||||
YouTubeSuperChat(response.data);
|
YouTubeSuperChat(response.data);
|
||||||
@@ -721,6 +728,30 @@ async function TwitchRaid(data) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function TwitchWatchStreak(data) {
|
||||||
|
if (!showTwitchWatchStreaks)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Render avatars
|
||||||
|
const avatarURL = await GetAvatar(data.userName, 'twitch');
|
||||||
|
|
||||||
|
// Set the text
|
||||||
|
const username = data.displayName;
|
||||||
|
const watchStreak = data.watchStreak;
|
||||||
|
|
||||||
|
UpdateAlertBox(
|
||||||
|
'twitch',
|
||||||
|
avatarURL,
|
||||||
|
`${username}`,
|
||||||
|
`is currently on a ${watchStreak}-stream streak!`,
|
||||||
|
'',
|
||||||
|
username,
|
||||||
|
'',
|
||||||
|
twitchWatchStreaksAction,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function YouTubeSuperChat(data) {
|
function YouTubeSuperChat(data) {
|
||||||
if (!showYouTubeSuperChats)
|
if (!showYouTubeSuperChats)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -312,6 +312,23 @@
|
|||||||
"showIf": "showTwitchRaids",
|
"showIf": "showTwitchRaids",
|
||||||
"group": "Which Twitch alerts do you want to see?"
|
"group": "Which Twitch alerts do you want to see?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "showTwitchWatchStreaks",
|
||||||
|
"label": "Watch Streaks",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": true,
|
||||||
|
"group": "Which Twitch alerts do you want to see?"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "twitchWatchStreaksAction",
|
||||||
|
"label": "",
|
||||||
|
"description": "Also run this Streamer.bot Action",
|
||||||
|
"type": "sb-actions",
|
||||||
|
"defaultValue": "",
|
||||||
|
"showIf": "showTwitchWatchStreaks",
|
||||||
|
"group": "Which Twitch alerts do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "showYouTubeSuperChats",
|
"id": "showYouTubeSuperChats",
|
||||||
"label": "Super Chats",
|
"label": "Super Chats",
|
||||||
|
|||||||
Reference in New Issue
Block a user