sync from github

This commit is contained in:
minster586
2025-08-25 01:16:23 -04:00
parent 3c95ac2361
commit 9384c57f43
53 changed files with 6941 additions and 1347 deletions

View File

@@ -0,0 +1,60 @@
/* ------------------------- */
/* PATREON MODULE VARIABLES */
/* ------------------------- */
const showPatreon = getURLParam("showPatreon", true);
const showPatreonMemberships = getURLParam("showPatreonMemberships", true);
// PATREON EVENTS HANDLERS
const patreonHandlers = {
'Patreon.PledgeCreated': (response) => {
patreonMemberships(response.data);
},
};
if (showPatreon) {
registerPlatformHandlersToStreamerBot(patreonHandlers, '[Patreon]');
}
// PATREON EVENTS FUNCTIONS
async function patreonMemberships(data) {
if (showPatreonMemberships == false) return;
const template = eventTemplate;
const clone = template.content.cloneNode(true);
const messageId = createRandomString(40);
const userId = createRandomString(40);
const {
header,
platform,
user,
action,
value,
'actual-message': message
} = Object.fromEntries(
[...clone.querySelectorAll('[class]')]
.map(el => [el.className, el])
);
const classes = ['patreon', 'membership'];
header.remove();
var money = (data.attributes.will_pay_amount_cents / 100).toFixed(2);
user.innerHTML = `<strong>${data.attributes.full_name}</strong>`;
action.innerHTML = ` donated `;
value.innerHTML = `<strong>${money}</strong>`;
message.remove();
addEventItem('patreon', clone, classes, userId, messageId);
}