sync from github
This commit is contained in:
38
js/modules/kofi/images/logo-kofi.svg
Normal file
38
js/modules/kofi/images/logo-kofi.svg
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 800 800">
|
||||
<!-- Generator: Adobe Illustrator 29.0.0, SVG Export Plug-In . SVG Version: 2.1.0 Build 186) -->
|
||||
<defs>
|
||||
<style>
|
||||
.st0 {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
.st1 {
|
||||
mask: url(#mask);
|
||||
}
|
||||
|
||||
.st2 {
|
||||
fill: #202020;
|
||||
}
|
||||
|
||||
.st3 {
|
||||
fill: #ff5a16;
|
||||
}
|
||||
</style>
|
||||
<mask id="mask" x="83" y="145.9" width="632" height="507.1" maskUnits="userSpaceOnUse">
|
||||
<g id="mask0_1_219">
|
||||
<path class="st0" d="M715,145.9H83v507.1h632V145.9Z"/>
|
||||
</g>
|
||||
</mask>
|
||||
</defs>
|
||||
<g class="st1">
|
||||
<g>
|
||||
<path class="st0" d="M335.7,653c-92,0-166.8-41.1-210.7-115.9-38.8-65.5-42-136.4-42-215.7s14.1-87.9,40.9-118.3c24.6-27.9,59.4-46,98-51,45.9-5.8,102.9-6.3,162.2-6.3,96.5,0,123.7,1.2,161.7,5,50.5,5,93,23.9,122.9,54.5,30.3,31.1,46.4,72.7,46.4,120.3v9.6c0,81.2-54.3,149.1-129.9,167.6-5.6,13.3-12.6,26.6-20.9,39.6l-.2.3c-26.6,41.2-89.3,110.3-209.2,110.3h-19.1,0Z"/>
|
||||
<path class="st0" d="M541.8,190.7c-35.9-3.6-60.9-4.8-157.7-4.8s-114.7.6-157.1,6c-56.2,7.2-104,50.2-104,129.7s4.2,141,36.4,195.4c36.4,62.1,97.4,96.2,176.3,96.2h19.1c96.8,0,149.4-51.4,175.7-92,11.4-17.9,19.7-35.8,25.1-53.8,68.7-6,119.5-62.7,119.5-132v-9.6c0-74.7-49-126.7-133.2-135h0Z"/>
|
||||
<path class="st2" d="M123,321.5c0-79.5,47.8-122.5,104-129.7,42.4-5.4,95-6,157.1-6,96.8,0,121.9,1.2,157.7,4.8,84.3,8.4,133.2,60.3,133.2,135v9.6c0,69.3-50.8,126.1-119.5,132-5.4,17.9-13.7,35.8-25.1,53.8-26.3,40.6-78.9,92-175.7,92h-19.1c-78.9,0-139.8-34.1-176.3-96.2-32.3-54.4-36.4-114.7-36.4-195.4"/>
|
||||
<path class="st0" d="M167.8,322.1c0,77.1,4.8,126.7,29.9,172.7,28.7,53.2,80.7,73.5,139.8,73.5h18.5c77.7,0,115.3-37.6,136.2-70.5,10.2-16.7,19.1-35.2,23.9-58.6l3.6-14.9h21.5c47.8,0,89-38.8,89-88.4v-9c0-55.6-34.6-84.9-95-92-34.1-3-54.4-4.2-151.2-4.2s-111.7.6-147,6c-49.6,7.2-69.3,35.2-69.3,85.4"/>
|
||||
<path class="st2" d="M519.7,363.3c0,7.2,5.4,12.6,14.9,12.6,30.5,0,47.2-17.3,47.2-46s-16.7-46.6-47.2-46.6-14.9,5.4-14.9,12.6v67.5h0Z"/>
|
||||
<path class="st3" d="M226.3,359.8c0,35.2,19.7,65.7,44.8,89.6,16.7,16.1,43,32.9,60.9,43.6,5.4,3,10.8,4.8,16.7,4.8s13.1-1.8,17.9-4.8c17.9-10.8,44.2-27.5,60.3-43.6,25.7-23.9,45.4-54.4,45.4-89.6s-28.7-72.3-69.9-72.3-41.2,12.6-53.8,29.9c-11.4-17.3-28.7-29.9-53.2-29.9-41.8,0-69.3,34-69.3,72.3"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.4 KiB |
11
js/modules/kofi/module.css
Normal file
11
js/modules/kofi/module.css
Normal file
@@ -0,0 +1,11 @@
|
||||
#chat .event.kofi .message {
|
||||
background: rgba(114, 165, 242,0.75);
|
||||
}
|
||||
|
||||
#chat .event.kofi .header {
|
||||
padding: 5px 0;
|
||||
text-align: center;
|
||||
}
|
||||
#chat .event.kofi .header img {
|
||||
height: 128px;
|
||||
}
|
192
js/modules/kofi/module.js
Normal file
192
js/modules/kofi/module.js
Normal file
@@ -0,0 +1,192 @@
|
||||
/* --------------------- */
|
||||
/* KOFI MODULE VARIABLES */
|
||||
/* --------------------- */
|
||||
|
||||
const showKofi = getURLParam("showKofi", true);
|
||||
|
||||
const showKofiSubscriptions = getURLParam("showKofiSubscriptions", true);
|
||||
const showKofiDonations = getURLParam("showKofiDonations", true);
|
||||
const showKofiOrders = getURLParam("showKofiOrders", true);
|
||||
|
||||
|
||||
// KOFI EVENTS HANDLERS
|
||||
|
||||
const kofiMessageHandlers = {
|
||||
'Kofi.Donation': (response) => {
|
||||
kofiDonationMessage(response.data);
|
||||
},
|
||||
'Kofi.Subscription': (response) => {
|
||||
kofiSubMessage(response.data);
|
||||
},
|
||||
'Kofi.Resubscription': (response) => {
|
||||
kofiReSubMessage(response.data);
|
||||
},
|
||||
'Kofi.ShopOrder': (response) => {
|
||||
kofiOrderMessage(response.data);
|
||||
},
|
||||
};
|
||||
|
||||
if (showKofi) {
|
||||
registerPlatformHandlersToStreamerBot(kofiMessageHandlers, '[Ko-Fi]');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// KOFI EVENT FUNCTIONS
|
||||
|
||||
async function kofiDonationMessage(data) {
|
||||
|
||||
if (kofiDonationMessage == 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 = ['kofi', 'donation'];
|
||||
|
||||
header.remove();
|
||||
|
||||
|
||||
user.innerHTML = `<strong>${data.from}</strong>`;
|
||||
action.innerHTML = ` donated `;
|
||||
|
||||
var money = formatCurrency(data.amount,data.currency);
|
||||
value.innerHTML = `<strong>${money}</strong>`;
|
||||
|
||||
if (data.message) message.innerHTML = `${data.message}`;
|
||||
|
||||
addEventItem('kofi', clone, classes, userId, messageId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function kofiSubMessage(data) {
|
||||
|
||||
if (showKofiSubscriptions == 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 = ['kofi', 'sub'];
|
||||
|
||||
header.remove();
|
||||
|
||||
|
||||
user.innerHTML = `<strong>${data.from}</strong>`;
|
||||
action.innerHTML = ` just subscribed `;
|
||||
|
||||
var money = formatCurrency(data.amount,data.currency);
|
||||
value.innerHTML = `<strong>(${money})</strong>`;
|
||||
|
||||
if (data.message) message.innerHTML = `${data.message}`;
|
||||
|
||||
addEventItem('kofi', clone, classes, userId, messageId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function kofiReSubMessage(data) {
|
||||
|
||||
if (showKofiSubscriptions == 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 = ['kofi', 'sub'];
|
||||
|
||||
header.remove();
|
||||
|
||||
|
||||
user.innerHTML = `<strong>${data.from}</strong>`;
|
||||
action.innerHTML = ` just resubscribed `;
|
||||
|
||||
var money = formatCurrency(data.amount,data.currency);
|
||||
value.innerHTML = `<strong>(${money}) ${data.tier ? '(Tier '+data.tier+')' : ''}</strong>`;
|
||||
|
||||
if (data.message) message.innerHTML = `${data.message}`;
|
||||
|
||||
addEventItem('kofi', clone, classes, userId, messageId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function kofiOrderMessage(data) {
|
||||
|
||||
if (showKofiOrders == 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 = ['kofi', 'sub'];
|
||||
|
||||
header.remove();
|
||||
|
||||
|
||||
user.innerHTML = `<strong>${data.from}</strong>`;
|
||||
action.innerHTML = ` just ordered `;
|
||||
|
||||
var money = '';
|
||||
if (data.amount == 0) money = 'Free';
|
||||
else money = formatCurrency(data.amount,data.currency);
|
||||
|
||||
value.innerHTML = `<strong>${data.items.length} ${data.items.length > 1 ? 'item' : 'items'} (${money})</strong>`;
|
||||
|
||||
if (data.message) message.innerHTML = `${data.message}`;
|
||||
|
||||
addEventItem('kofi', clone, classes, userId, messageId);
|
||||
}
|
Reference in New Issue
Block a user