diff --git a/images/3k7a2BA.png b/images/3k7a2BA.png new file mode 100644 index 0000000..be3e7ea Binary files /dev/null and b/images/3k7a2BA.png differ diff --git a/index.html b/index.html index 06f7b1f..9c787cf 100644 --- a/index.html +++ b/index.html @@ -313,6 +313,6 @@ - + diff --git a/js/app-mockup.js b/js/app-mockup.js index b986e46..eeb5a86 100644 --- a/js/app-mockup.js +++ b/js/app-mockup.js @@ -219,6 +219,10 @@ function generateMockEvent() { 'patreon-membership', 'tipeeestream-tip', + 'kofi-donation', 'kofi-sub', 'kofi-resub', 'kofi-order', + + 'fourthwall-donation', 'fourthwall-sub', 'fourthwall-order', + 'streamlabs-tip', 'streamelements-tip', ]; @@ -770,6 +774,127 @@ function generateMockEvent() { + case 'kofi-donation' : + + var data = { + from: user.name, + amount: Math.floor(Math.random() * 2000) + 1, + currency: 'USD', + message: messagetext + }; + + kofiDonationMessage(data); + + break; + + + case 'kofi-sub' : + + var data = { + from: user.name, + amount: Math.floor(Math.random() * 2000) + 1, + currency: 'USD', + message: messagetext + }; + + kofiSubMessage(data); + + break; + + case 'kofi-resub' : + + var data = { + from: user.name, + amount: Math.floor(Math.random() * 2000) + 1, + currency: 'USD', + tier: parseInt(Math.floor(Math.random() * 3) + 1), + message: messagetext + }; + + kofiReSubMessage(data); + + break; + + case 'kofi-order' : + + var data = { + from: user.name, + amount: Math.floor(Math.random() * 200) + 1, + items: badgeschosen, + currency: 'USD', + message: messagetext + }; + + kofiOrderMessage(data); + + break; + + + + + + + + + + + + case 'fourthwall-donation' : + + var data = { + username: user.name, + amount: Math.floor(Math.random() * 2000) + 1, + currency: 'USD', + message: messagetext + }; + + fourthwallDonationMessage(data); + + break; + + + case 'fourthwall-sub' : + + var data = { + nickname: user.name, + amount: Math.floor(Math.random() * 2000) + 1, + currency: 'USD' + }; + + fourthwallSubMessage(data); + + break; + + + case 'fourthwall-order' : + + var data = { + username: user.name, + total: Math.floor(Math.random() * 200) + 1, + variants: [ + { + name: 'Fake Product', + image: 'images/3k7a2BA.png' + } + ], + currency: 'USD', + statmessageus: messagetext + }; + + fourthwallOrderMessage(data); + + break; + + + + + + + + + + + case 'streamlabs-tip' : var data = { diff --git a/js/fourthwall/module.js b/js/fourthwall/module.js index 724f981..f4e83e4 100644 --- a/js/fourthwall/module.js +++ b/js/fourthwall/module.js @@ -1,20 +1,53 @@ -const showShopifyOrders = getURLParam("showShopifyOrders", true); +const showFourthwallDonations = getURLParam("showFourthwallDonations", true); -const shopifyMessageHandlers = { - 'Shopify.OrderPaid': (response) => { - console.debug('Shopify Order Paid', response.data); - //shopifyOrderPaidMessage(response.data); +const showFourthwallOrders = getURLParam("showFourthwallOrders", true); +const showFourthwallShowImage = getURLParam("showFourthwallShowImage", true); +const showFourthwallBigImage = getURLParam("showFourthwallBigImage", true); + +const showFourthwallSubscriptions = getURLParam("showFourthwallSubscriptions", true); + +const showFourthwallGiftPurchase = getURLParam("showFourthwallGiftPurchase", true); +const showFourthwallShowGiftImage = getURLParam("showFourthwallShowGiftImage", true); +const showFourthwallBigGiftImage = getURLParam("showFourthwallBigGiftImage", true); + +const showFourthwallGiftDraw = getURLParam("showFourthwallGiftDraw", true); +const fourthWallGiftDrawCommand = getURLParam("fourthWallGiftDrawCommand", "!enter"); + +const fourthwallMessageHandlers = { + 'Fourthwall.Donation': (response) => { + console.debug('Fourthwall Donation', response.data); + fourthwallDonationMessage(response.data); + }, + 'Fourthwall.OrderPlaced': (response) => { + console.debug('Fourthwall Order', response.data); + fourthwallOrderMessage(response.data); + }, + 'Fourthwall.SubscriptionPurchased': (response) => { + console.debug('Fourthwall Sub', response.data); + fourthwallSubMessage(response.data); + }, + 'Fourthwall.GiftPurchase': (response) => { + console.debug('Fourthwall Gift', response.data); + fourthwallGiftMessage(response.data); + }, + 'Fourthwall.GiftDrawStarted': (response) => { + console.debug('Fourthwall Gift Draw Start', response.data); + fourthwallGiftDrawStartMessage(response.data); + }, + 'Fourthwall.GiftDrawEnded': (response) => { + console.debug('Fourthwall Gift Draw Start', response.data); + fourthwallGiftDrawEndMessage(response.data); }, }; -for (const [event, handler] of Object.entries(shopifyMessageHandlers)) { +for (const [event, handler] of Object.entries(fourthwallMessageHandlers)) { streamerBotClient.on(event, handler); } -async function shopifyOrderPaidMessage(data) { +async function fourthwallDonationMessage(data) { - if (showShopifyOrders == false) return; + if (showFourthwallDonations == false) return; const { username : userName, @@ -181,7 +214,7 @@ async function fourthwallGiftMessage(data) { }), ]); - const classes = ['gift']; + const classes = ['order']; if (showFourthwallBigGiftImage == true) { classes.push('giantimage'); } @@ -210,6 +243,7 @@ async function fourthwallGiftDrawStartMessage(data) { durationSeconds } = data; + var userName = ''; const userID = createRandomString(40); const messageID = createRandomString(40); @@ -217,7 +251,8 @@ async function fourthwallGiftDrawStartMessage(data) { '', currentLang.fourthwall.drawstart({ gift: itemName, - command: fourthWallGiftDrawCommand + command: fourthWallGiftDrawCommand, + time: durationSeconds }), ]); @@ -240,18 +275,17 @@ async function fourthwallGiftDrawEndMessage(data) { if (showFourthwallGiftDraw == false) return; const { - data: { - gifts - } + gifts } = data; + var userName = ''; const userID = createRandomString(40); const messageID = createRandomString(40); const [avatar, message] = await Promise.all([ '', currentLang.fourthwall.drawend({ - winners: getWinnersList(gifts) + winners: await getWinnersList(gifts) }), ]); diff --git a/js/kofi/module.js b/js/kofi/module.js index 6f48ea4..93087b3 100644 --- a/js/kofi/module.js +++ b/js/kofi/module.js @@ -110,6 +110,8 @@ async function kofiReSubMessage(data) { const { from : userName, + amount, + currency, tier, message: text } = data; @@ -117,9 +119,12 @@ async function kofiReSubMessage(data) { const userID = createRandomString(40); const messageID = createRandomString(40); + var money = formatCurrency(amount,currency); + const [avatar, message] = await Promise.all([ '', currentLang.kofi.resub({ + money: money, tier: tier, message: text }), @@ -147,7 +152,6 @@ async function kofiOrderMessage(data) { from : userName, amount, currency, - message: text, items } = data; diff --git a/js/lang/en.js b/js/lang/en.js index d31e258..a953491 100644 --- a/js/lang/en.js +++ b/js/lang/en.js @@ -106,8 +106,8 @@ const en = { kofi : { donation : ({ money, message }) => ` donated 🪙 ${money}${message ? '
'+message : ''}`, - sub : ({ money, tier, message }) => ` subscribed ${money}${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, - resub : ({ money, tier, message }) => ` subscribed ${money}${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, + sub : ({ money, tier, message }) => ` subscribed (${money}) ${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, + resub : ({ money, tier, message }) => ` subscribed ${money} ${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, order : ({ money, items }) => ` ordered ${items} ${items == 1 ? 'item' : 'items'} (${money == 0 ? 'Free' : money})`, }, @@ -149,13 +149,13 @@ const en = { - drawstart : ({ gift, command }) => ` - Giveaway started! - Type ${command} to have a chance to win ${gift}`, + drawstart : ({ gift, command, time }) => ` + Giveaway started! +
Type ${command} to have a chance to win ${gift}. You have ${time} seconds!`, drawend : ({ winners }) => ` 🎉 Giveaway Ended! - Congratulations ${winners}`, +
Congratulations ${winners}`, diff --git a/js/settings.js b/js/settings.js index 9c86aaa..8f3b061 100644 --- a/js/settings.js +++ b/js/settings.js @@ -369,4 +369,4 @@ document.querySelectorAll('.nav-bar a').forEach(anchor => { }); } }); -}); +}); \ No newline at end of file