Added Patreon support

This commit is contained in:
nuttylmao
2025-03-27 06:27:13 +11:00
parent e50925e11d
commit 56f47d4cdb
10 changed files with 85 additions and 6 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+21 -2
View File
@@ -46,6 +46,7 @@ const showYouTubeMemberships = GetBooleanParam("showYouTubeMemberships", true);
const showStreamlabsDonations = GetBooleanParam("showStreamlabsDonations", true)
const showStreamElementsTips = GetBooleanParam("showStreamElementsTips", true);
const showPatreonMemberships = GetBooleanParam("showPatreonMemberships", true);
// Set fonts for the widget
document.body.style.fontFamily = font;
@@ -184,6 +185,11 @@ client.on('StreamElements.Tip', (response) => {
StreamElementsTip(response.data);
})
client.on('Patreon.PledgeCreated', (response) => {
console.debug(response.data);
PatreonPledgeCreated(response.data);
})
/////////////////////
@@ -199,7 +205,7 @@ async function TwitchChatMessage(data) {
return;
// Don't post messages from users from the ignore list
if (ignoreUserList.includes(data.message.username))
if (ignoreUserList.includes(data.message.username.toLowerCase()))
return;
// Get a reference to the template
@@ -500,7 +506,7 @@ function YouTubeMessage(data) {
return;
// Don't post messages from users from the ignore list
if (ignoreUserList.includes(data.user.name))
if (ignoreUserList.includes(data.user.name.toLowerCase()))
return;
// Get a reference to the template
@@ -666,6 +672,19 @@ function StreamElementsTip(data) {
ShowAlert(message, 'streamelements');
}
function PatreonPledgeCreated(data) {
if (!showPatreonMemberships)
return;
const user = data.attributes.full_name;
const amount = (data.attributes.will_pay_amount_cents/100).toFixed(2);
const patreonIcon = `<img src="icons/platforms/patreon.png" class="platform"/>`;
let message = `${patreonIcon} ${user} joined Patreon ($${amount})`;
ShowAlert(message, 'patreon');
}
//////////////////////
-1
View File
@@ -1,5 +1,4 @@
let settingsContainer = document.getElementById('settings-container');
//settingsContainer.src = `https://nuttylmao.github.io/widget-customizer?settingsJson=${window.location.href}/settings.json`
settingsContainer.src = `../../widget-customizer?settingsJson=${window.location.href}/settings.json`
console.log(settingsContainer.src);
+8
View File
@@ -207,6 +207,14 @@
"defaultValue": true,
"group": "Which donation messages do you want to see?"
},
{
"id": "showPatreonMemberships",
"label": "Patreon Memberships",
"description": "",
"type": "checkbox",
"defaultValue": true,
"group": "Which donation messages do you want to see?"
},
{
"id": "address",
"label": "Address",
+4
View File
@@ -241,6 +241,10 @@ li {
background: linear-gradient(#263b8abf, #0a112abf) !important;
}
.patreon {
background: linear-gradient(#c76633, #fd5e0a) !important;
}
/****************/
/** ANIMATIONS **/
/****************/
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+39 -2
View File
@@ -45,6 +45,7 @@ const showYouTubeMemberships = GetBooleanParam("showYouTubeMemberships", true);
const showStreamlabsDonations = GetBooleanParam("showStreamlabsDonations", true)
const showStreamElementsTips = GetBooleanParam("showStreamElementsTips", true);
const showPatreonMemberships = GetBooleanParam("showPatreonMemberships", true);
// Set fonts for the widget
document.body.style.fontFamily = font;
@@ -198,6 +199,11 @@ client.on('StreamElements.Tip', (response) => {
StreamElementsTip(response.data);
})
client.on('Patreon.PledgeCreated', (response) => {
console.debug(response.data);
PatreonPledgeCreated(response.data);
})
///////////////////////
@@ -213,7 +219,7 @@ async function TwitchChatMessage(data) {
return;
// Don't post messages from users from the ignore list
if (ignoreUserList.includes(data.message.username))
if (ignoreUserList.includes(data.message.username.toLowerCase()))
return;
// Get a reference to the template
@@ -783,7 +789,7 @@ function YouTubeMessage(data) {
return;
// Don't post messages from users from the ignore list
if (ignoreUserList.includes(data.user.name))
if (ignoreUserList.includes(data.user.name.toLowerCase()))
return;
// Get a reference to the template
@@ -1097,6 +1103,37 @@ async function StreamElementsTip(data) {
AddMessageItem(instance, data.id);
}
function PatreonPledgeCreated(data) {
if (!showPatreonMemberships)
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('patreon');
// Set the text
const user = data.attributes.full_name;
const amount = (data.attributes.will_pay_amount_cents/100).toFixed(2);
const patreonIcon = `<img src="icons/platforms/patreon.png" class="platform"/>`;
titleDiv.innerHTML = `${patreonIcon} ${user} joined Patreon ($${amount})`;
AddMessageItem(instance, data.id);
}
//////////////////////
+1 -1
View File
@@ -1,5 +1,5 @@
let settingsContainer = document.getElementById('settings-container');
settingsContainer.src = `https://widgets.nutty.gg/widget-customizer?settingsJson=${window.location.href}/settings.json`
settingsContainer.src = `../../widget-customizer?settingsJson=${window.location.href}/settings.json`
console.log(settingsContainer.src);
function reloadWidget(data) {
+8
View File
@@ -269,6 +269,14 @@
"defaultValue": true,
"group": "Which donation messages do you want to see?"
},
{
"id": "showPatreonMemberships",
"label": "Patreon Memberships",
"description": "",
"type": "checkbox",
"defaultValue": true,
"group": "Which donation messages do you want to see?"
},
{
"id": "address",
"label": "Address",
+4
View File
@@ -207,6 +207,10 @@ li {
background: linear-gradient(#263b8abf, #0a112abf) !important;
}
.patreon {
background: linear-gradient(#c76633, #fd5e0a) !important;
}
/****************/
/** ANIMATIONS **/
/****************/