mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-19 04:00:59 -04:00
Added Patreon support
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////
|
||||
|
||||
Reference in New Issue
Block a user