mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-19 04:00:59 -04:00
Added support for Cheer alerts
This commit is contained in:
@@ -41,6 +41,7 @@ const ignoreChatters = urlParams.get("ignoreChatters") || "";
|
|||||||
const groupConsecutiveMessages = GetBooleanParam("groupConsecutiveMessages", true);
|
const groupConsecutiveMessages = GetBooleanParam("groupConsecutiveMessages", true);
|
||||||
|
|
||||||
const showTwitchMessages = GetBooleanParam("showTwitchMessages", true);
|
const showTwitchMessages = GetBooleanParam("showTwitchMessages", true);
|
||||||
|
const showTwitchCheers = GetBooleanParam("showTwitchCheers", false);
|
||||||
const showTwitchAnnouncements = GetBooleanParam("showTwitchAnnouncements", true);
|
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);
|
||||||
@@ -139,7 +140,7 @@ client.on('Twitch.ChatMessage', (response) => {
|
|||||||
|
|
||||||
client.on('Twitch.Cheer', (response) => {
|
client.on('Twitch.Cheer', (response) => {
|
||||||
console.debug(response.data);
|
console.debug(response.data);
|
||||||
TwitchChatMessage(response.data);
|
TwitchCheer(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('Twitch.Announcement', (response) => {
|
client.on('Twitch.Announcement', (response) => {
|
||||||
@@ -621,6 +622,22 @@ async function TwitchChatMessage(data) {
|
|||||||
AddMessageItem(instance, data.message.msgId, 'twitch', data.user.id);
|
AddMessageItem(instance, data.message.msgId, 'twitch', data.user.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function TwitchCheer(data) {
|
||||||
|
TwitchChatMessage(data);
|
||||||
|
if (!showTwitchCheers)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Set the text
|
||||||
|
let username = data.user.name;
|
||||||
|
if (data.user.name.toLowerCase() != data.user.login.toLowerCase())
|
||||||
|
username = `${data.user.name} (${data.user.login})`;
|
||||||
|
let bits = data.bits;
|
||||||
|
|
||||||
|
const message = `${username} cheered ${bits} bits`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'twitch');
|
||||||
|
}
|
||||||
|
|
||||||
async function TwitchAnnouncement(data) {
|
async function TwitchAnnouncement(data) {
|
||||||
if (!showTwitchAnnouncements)
|
if (!showTwitchAnnouncements)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -135,6 +135,14 @@
|
|||||||
"defaultValue": true,
|
"defaultValue": true,
|
||||||
"group": "Which Twitch messages do you want to see?"
|
"group": "Which Twitch messages do you want to see?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "showTwitchCheers",
|
||||||
|
"label": "Cheers",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": false,
|
||||||
|
"group": "Which Twitch messages do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "showTwitchAnnouncements",
|
"id": "showTwitchAnnouncements",
|
||||||
"label": "Announcements",
|
"label": "Announcements",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const imageEmbedPermissionLevel = GetIntParam("imageEmbedPermissionLevel", 20);
|
|||||||
const showYouTubeLinkPreviews = GetBooleanParam("showYouTubeLinkPreviews", true);
|
const showYouTubeLinkPreviews = GetBooleanParam("showYouTubeLinkPreviews", true);
|
||||||
|
|
||||||
const showTwitchMessages = GetBooleanParam("showTwitchMessages", true);
|
const showTwitchMessages = GetBooleanParam("showTwitchMessages", true);
|
||||||
|
const showTwitchCheers = GetBooleanParam("showTwitchCheers", false);
|
||||||
const showTwitchAnnouncements = GetBooleanParam("showTwitchAnnouncements", true);
|
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);
|
||||||
@@ -158,7 +159,7 @@ client.on('Twitch.ChatMessage', (response) => {
|
|||||||
|
|
||||||
client.on('Twitch.Cheer', (response) => {
|
client.on('Twitch.Cheer', (response) => {
|
||||||
console.debug(response.data);
|
console.debug(response.data);
|
||||||
TwitchChatMessage(response.data);
|
TwitchCheer(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('Twitch.AutomaticRewardRedemption', (response) => {
|
client.on('Twitch.AutomaticRewardRedemption', (response) => {
|
||||||
@@ -752,6 +753,49 @@ async function TwitchChatMessage(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function TwitchCheer(data) {
|
||||||
|
TwitchChatMessage(data);
|
||||||
|
if (!showTwitchCheers)
|
||||||
|
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("#contentDiv");
|
||||||
|
|
||||||
|
// 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})`;
|
||||||
|
let bits = data.bits;
|
||||||
|
|
||||||
|
titleDiv.innerText = `${username} cheered ${bits} bits`;
|
||||||
|
|
||||||
|
AddMessageItem(instance, data.messageId);
|
||||||
|
}
|
||||||
|
|
||||||
async function TwitchAutomaticRewardRedemption(data) {
|
async function TwitchAutomaticRewardRedemption(data) {
|
||||||
// Get a reference to the template
|
// Get a reference to the template
|
||||||
const template = document.getElementById('messageTemplate');
|
const template = document.getElementById('messageTemplate');
|
||||||
|
|||||||
@@ -242,6 +242,14 @@
|
|||||||
"defaultValue": true,
|
"defaultValue": true,
|
||||||
"group": "Which Twitch messages do you want to see?"
|
"group": "Which Twitch messages do you want to see?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "showTwitchCheers",
|
||||||
|
"label": "Cheers",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": false,
|
||||||
|
"group": "Which Twitch messages do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "showTwitchAnnouncements",
|
"id": "showTwitchAnnouncements",
|
||||||
"label": "Announcements",
|
"label": "Announcements",
|
||||||
|
|||||||
Reference in New Issue
Block a user