mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-19 04:00:59 -04:00
Added support for Kick kicks
This commit is contained in:
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.3 KiB |
+37
-18
@@ -58,6 +58,7 @@ const showKickMessages = GetBooleanParam("showKickMessages", true);
|
|||||||
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
||||||
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
||||||
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
||||||
|
const showKickGifts = GetBooleanParam("showKickGifts", true);
|
||||||
|
|
||||||
const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true);
|
const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true);
|
||||||
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
||||||
@@ -301,7 +302,9 @@ async function KickConnect() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Channel to subscribe to (you'll need the correct channel name here)
|
// Channel to subscribe to (you'll need the correct channel name here)
|
||||||
const chatroomId = await GetKickChatroomId(kickUsername);
|
const kickIds = await GetKickIds(kickUsername);
|
||||||
|
const chatroomId = kickIds.chatroomId;
|
||||||
|
const channelId = kickIds.channelId;
|
||||||
|
|
||||||
// Cache subscriber badges
|
// Cache subscriber badges
|
||||||
kickSubBadges = await GetKickSubBadges(kickUsername);
|
kickSubBadges = await GetKickSubBadges(kickUsername);
|
||||||
@@ -334,6 +337,7 @@ async function KickConnect() {
|
|||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
||||||
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `channel_${channelId}` } }));
|
||||||
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +369,9 @@ async function KickConnect() {
|
|||||||
case 'UserBannedEvent':
|
case 'UserBannedEvent':
|
||||||
KickUserBanned(eventArgs);
|
KickUserBanned(eventArgs);
|
||||||
break;
|
break;
|
||||||
|
case 'KicksGifted':
|
||||||
|
KickKicksGifted(eventArgs);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -1425,6 +1432,18 @@ function KickUserBanned(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function KickKicksGifted(data) {
|
||||||
|
if (!showKickGifts)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const kicksImg = `<img src=icons/badges/kick-kicks.svg class="platform"/>`;
|
||||||
|
const giftImg = `<img src=https://files.kick.com/kicks/gifts/${data.gift.gift_id.replace('_', '-')}.webp class="platform"/>`;
|
||||||
|
|
||||||
|
const message = ` ${giftImg} ${data.sender.username} sent ${data.gift.name} ${kicksImg} ${data.gift.amount}`;
|
||||||
|
|
||||||
|
ShowAlert(message, 'kick');
|
||||||
|
}
|
||||||
|
|
||||||
async function TikTokChat(data) {
|
async function TikTokChat(data) {
|
||||||
if (!showTikTokMessages)
|
if (!showTikTokMessages)
|
||||||
return;
|
return;
|
||||||
@@ -1863,25 +1882,25 @@ function EscapeRegExp(string) {
|
|||||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GetKickChatroomId(username) {
|
async function GetKickIds(username) {
|
||||||
const url = `https://kick.com/api/v2/channels/${username}`;
|
const url = `https://kick.com/api/v2/channels/${username}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error ${response.status}`);
|
throw new Error(`HTTP error ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.chatroom && data.chatroom.id) {
|
if (data.chatroom && data.chatroom.id) {
|
||||||
return data.chatroom.id;
|
return { chatroomId: data.chatroom.id, channelId: data.chatroom.channel_id };
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Chatroom ID not found in response.");
|
throw new Error("Chatroom ID not found in response.");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch chatroom ID:", error.message);
|
console.error("Failed to fetch chatroom ID:", error.message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GetKickSubBadges(username) {
|
async function GetKickSubBadges(username) {
|
||||||
|
|||||||
@@ -255,6 +255,14 @@
|
|||||||
"defaultValue": true,
|
"defaultValue": true,
|
||||||
"group": "Which Kick messages do you want to see?"
|
"group": "Which Kick messages do you want to see?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "showKickGifts",
|
||||||
|
"label": "Gifts",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": true,
|
||||||
|
"group": "Which Kick messages do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "enableTikTokSupport",
|
"id": "enableTikTokSupport",
|
||||||
"label": "Enable TikTok Support",
|
"label": "Enable TikTok Support",
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ html {
|
|||||||
/* background-color: red; */
|
/* background-color: red; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#alertBoxContent img {
|
||||||
|
height: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
#background {
|
#background {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.3 KiB |
@@ -66,7 +66,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id="tiktok-gift-template">
|
<template id="tiktok-gift-template">
|
||||||
<div class="tiktok-gift">
|
<div class="tiktok-gift tiktok">
|
||||||
<img class="tiktok-gift-avatar"
|
<img class="tiktok-gift-avatar"
|
||||||
src="https://static-cdn.jtvnw.net/jtv_user_pictures/f632e0c6-38e2-4065-a29e-6ba9b3e8cacf-profile_image-300x300.png" />
|
src="https://static-cdn.jtvnw.net/jtv_user_pictures/f632e0c6-38e2-4065-a29e-6ba9b3e8cacf-profile_image-300x300.png" />
|
||||||
<div class="tiktok-gift-message">
|
<div class="tiktok-gift-message">
|
||||||
@@ -84,6 +84,27 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template id="kick-gift-template">
|
||||||
|
<div class="kick-gift kick">
|
||||||
|
<img class="kick-gift-avatar"
|
||||||
|
src="" />
|
||||||
|
<div class="kick-gift-contents">
|
||||||
|
<span id="kick-gift-username" style="font-weight: 700;">
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
<div style="display: flex; flex-direction: row; align-items: center;">
|
||||||
|
<span>sent <span id="kick-gift-name"></span></span>
|
||||||
|
<img src="icons/badges/kick-kicks.svg" style="height: 1em; padding-left: 0.5em; padding-right: 0.25em;">
|
||||||
|
<span id="kick-gift-amount">13</span>
|
||||||
|
</div>
|
||||||
|
<div id="kick-gift-message">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<img class="kick-gift-sticker"
|
||||||
|
src="" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script src="./script.js"></script>
|
<script src="./script.js"></script>
|
||||||
+59
-18
@@ -61,6 +61,7 @@ const showKickMessages = GetBooleanParam("showKickMessages", true);
|
|||||||
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
const showKickSubs = GetBooleanParam("showKickSubs", true);
|
||||||
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRedemptions", true);
|
||||||
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
||||||
|
const showKickGifts = GetBooleanParam("showKickGifts", true);
|
||||||
|
|
||||||
const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true);
|
const showYouTubeMessages = GetBooleanParam("showYouTubeMessages", true);
|
||||||
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
||||||
@@ -322,6 +323,11 @@ client.on('Fourthwall.GiftDrawEnded', (response) => {
|
|||||||
FourthwallGiftDrawEnded(response.data);
|
FourthwallGiftDrawEnded(response.data);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
client.on('Fourthwall.GiftDrawEnded', (response) => {
|
||||||
|
console.debug(response.data);
|
||||||
|
FourthwallGiftDrawEnded(response.data);
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
@@ -334,7 +340,9 @@ async function KickConnect() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Channel to subscribe to (you'll need the correct channel name here)
|
// Channel to subscribe to (you'll need the correct channel name here)
|
||||||
const chatroomId = await GetKickChatroomId(kickUsername);
|
const kickIds = await GetKickIds(kickUsername);
|
||||||
|
const chatroomId = kickIds.chatroomId;
|
||||||
|
const channelId = kickIds.channelId;
|
||||||
|
|
||||||
// Cache subscriber badges
|
// Cache subscriber badges
|
||||||
kickSubBadges = await GetKickSubBadges(kickUsername);
|
kickSubBadges = await GetKickSubBadges(kickUsername);
|
||||||
@@ -367,6 +375,7 @@ async function KickConnect() {
|
|||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
||||||
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `channel_${channelId}` } }));
|
||||||
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,6 +407,9 @@ async function KickConnect() {
|
|||||||
case 'UserBannedEvent':
|
case 'UserBannedEvent':
|
||||||
KickUserBanned(eventArgs);
|
KickUserBanned(eventArgs);
|
||||||
break;
|
break;
|
||||||
|
case 'KicksGifted':
|
||||||
|
KickKicksGifted(eventArgs);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -2518,6 +2530,35 @@ function KickMessageDeleted(data) {
|
|||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function KickKicksGifted(data) {
|
||||||
|
if (!showKickGifts)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Get a reference to the template
|
||||||
|
const template = document.getElementById('kick-gift-template');
|
||||||
|
|
||||||
|
// Create a new instance of the template
|
||||||
|
const instance = template.content.cloneNode(true);
|
||||||
|
|
||||||
|
// Get divs
|
||||||
|
const avatarImg = instance.querySelector('.kick-gift-avatar');
|
||||||
|
const usernameSpan = instance.querySelector('#kick-gift-username');
|
||||||
|
const giftNameSpan = instance.querySelector('#kick-gift-name');
|
||||||
|
const stickerImg = instance.querySelector('.kick-gift-sticker');
|
||||||
|
const amountDiv = instance.querySelector('#kick-gift-amount');
|
||||||
|
const messageDiv = instance.querySelector('#kick-gift-message');
|
||||||
|
|
||||||
|
avatarImg.src = await GetAvatar(data.sender.username.replace('_', '-'), 'kick'); // Set the card header
|
||||||
|
usernameSpan.innerText = data.sender.username; // Set the username
|
||||||
|
usernameSpan.style.color = data.sender.username_color;
|
||||||
|
giftNameSpan.innerText = data.gift.name; // Set the gift name
|
||||||
|
stickerImg.src = `https://files.kick.com/kicks/gifts/${data.gift.gift_id.replace('_', '-')}.webp`; // Set the sticker image URL
|
||||||
|
amountDiv.innerText = data.gift.amount; // Set the number of gifts sent
|
||||||
|
messageDiv.innerText = data.message // Set the message
|
||||||
|
|
||||||
|
AddMessageItem(instance, null, 'kick', data.senderId);
|
||||||
|
}
|
||||||
|
|
||||||
function KickUserBanned(data) {
|
function KickUserBanned(data) {
|
||||||
const messageList = document.getElementById("messageList");
|
const messageList = document.getElementById("messageList");
|
||||||
|
|
||||||
@@ -3188,25 +3229,25 @@ function EscapeRegExp(string) {
|
|||||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GetKickChatroomId(username) {
|
async function GetKickIds(username) {
|
||||||
const url = `https://kick.com/api/v2/channels/${username}`;
|
const url = `https://kick.com/api/v2/channels/${username}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error ${response.status}`);
|
throw new Error(`HTTP error ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.chatroom && data.chatroom.id) {
|
if (data.chatroom && data.chatroom.id) {
|
||||||
return data.chatroom.id;
|
return { chatroomId: data.chatroom.id, channelId: data.chatroom.channel_id };
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Chatroom ID not found in response.");
|
throw new Error("Chatroom ID not found in response.");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch chatroom ID:", error.message);
|
console.error("Failed to fetch chatroom ID:", error.message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GetKickSubBadges(username) {
|
async function GetKickSubBadges(username) {
|
||||||
|
|||||||
@@ -376,6 +376,14 @@
|
|||||||
"defaultValue": true,
|
"defaultValue": true,
|
||||||
"group": "Which Kick messages do you want to see?"
|
"group": "Which Kick messages do you want to see?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "showKickGifts",
|
||||||
|
"label": "Gifts",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": true,
|
||||||
|
"group": "Which Kick messages do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "enableTikTokSupport",
|
"id": "enableTikTokSupport",
|
||||||
"label": "Enable TikTok Support",
|
"label": "Enable TikTok Support",
|
||||||
|
|||||||
@@ -224,17 +224,18 @@ li {
|
|||||||
transform: translate(0px, 0.25em);
|
transform: translate(0px, 0.25em);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.kick-gift,
|
||||||
.tiktok-gift {
|
.tiktok-gift {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
padding: 0.5em 1em;
|
padding: 0.5em;
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
background: linear-gradient(#262626BF, #000000BF) !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.kick-gift-avatar,
|
||||||
.tiktok-gift-avatar {
|
.tiktok-gift-avatar {
|
||||||
height: 3em;
|
height: 3em;
|
||||||
margin: 1px;
|
margin: 1px;
|
||||||
@@ -243,17 +244,37 @@ li {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.kick-gift-contents,
|
||||||
.tiktok-gift-message {
|
.tiktok-gift-message {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
white-space: nowrap; /* keeps text in a single line */
|
/* white-space: nowrap;
|
||||||
overflow: hidden; /* hides overflowed content */
|
overflow: hidden;
|
||||||
text-overflow: ellipsis; /* adds the "..." at the end */
|
text-overflow: ellipsis; */
|
||||||
|
gap: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kick-gift-contents {
|
||||||
|
/* text-align: center; */
|
||||||
|
}
|
||||||
|
|
||||||
|
#kick-gift-message {
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kick-gift-sticker,
|
||||||
|
.tiktok-gift-sticker {
|
||||||
|
flex-shrink: 0;
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
filter: drop-shadow(5px 5px 5px #00000060);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tiktok-gift-sticker {
|
.tiktok-gift-sticker {
|
||||||
height: 2.5em;
|
height: 2.5em;
|
||||||
flex-shrink: 0;
|
}
|
||||||
justify-content: flex-end;
|
|
||||||
|
.kick-gift-sticker {
|
||||||
|
height: 5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tiktok-gift-repeat-count {
|
#tiktok-gift-repeat-count {
|
||||||
@@ -292,7 +313,7 @@ li {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kick {
|
.kick {
|
||||||
background: linear-gradient(#53fc18, #005600) !important;
|
background: linear-gradient(#32b602, #005600) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.streamlabs {
|
.streamlabs {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.3 KiB |
@@ -77,6 +77,8 @@ const showKickChannelPointRedemptions = GetBooleanParam("showKickChannelPointRed
|
|||||||
const kickChannelPointRedemptionAction = urlParams.get("kickChannelPointRedemptionAction") || "";
|
const kickChannelPointRedemptionAction = urlParams.get("kickChannelPointRedemptionAction") || "";
|
||||||
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
const showKickHosts = GetBooleanParam("showKickHosts", true);
|
||||||
const kickHostAction = urlParams.get("kickHostAction") || "";
|
const kickHostAction = urlParams.get("kickHostAction") || "";
|
||||||
|
const showKickGifts = GetBooleanParam("showKickGifts", true);
|
||||||
|
const kickGiftAction = urlParams.get("kickGiftAction") || "";
|
||||||
|
|
||||||
// Which YouTube alerts do you want to see?
|
// Which YouTube alerts do you want to see?
|
||||||
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
const showYouTubeSuperChats = GetBooleanParam("showYouTubeSuperChats", true);
|
||||||
@@ -315,7 +317,9 @@ async function KickConnect() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Channel to subscribe to (you'll need the correct channel name here)
|
// Channel to subscribe to (you'll need the correct channel name here)
|
||||||
const chatroomId = await GetKickChatroomId(kickUsername);
|
const kickIds = await GetKickIds(kickUsername);
|
||||||
|
const chatroomId = kickIds.chatroomId;
|
||||||
|
const channelId = kickIds.channelId;
|
||||||
|
|
||||||
// Cache subscriber badges
|
// Cache subscriber badges
|
||||||
kickSubBadges = await GetKickSubBadges(kickUsername);
|
kickSubBadges = await GetKickSubBadges(kickUsername);
|
||||||
@@ -348,6 +352,7 @@ async function KickConnect() {
|
|||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `chatrooms.${chatroomId}.v2` } }));
|
||||||
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `predictions-channel-${chatroomId}` } }));
|
||||||
|
websocket.send(JSON.stringify({ event: 'pusher:subscribe', data: { channel: `channel_${channelId}` } }));
|
||||||
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
console.log(`[Pusher] Sent subscription request to channel: ${chatroomId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,6 +375,9 @@ async function KickConnect() {
|
|||||||
case 'StreamHostEvent':
|
case 'StreamHostEvent':
|
||||||
KickStreamHost(eventArgs);
|
KickStreamHost(eventArgs);
|
||||||
break;
|
break;
|
||||||
|
case 'KicksGifted':
|
||||||
|
KickKicksGifted(eventArgs);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -1365,6 +1373,33 @@ async function KickStreamHost(data) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function KickKicksGifted(data) {
|
||||||
|
if (!showKickGifts)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Set the text
|
||||||
|
const username = data.sender.username;
|
||||||
|
const tiktokIcon = `<img src="icons/platforms/kick.png" class="platform"/>`;
|
||||||
|
// const giftImg = `<img src=https://files.kick.com/kicks/gifts/${data.gift.gift_id.replace('_', '-')}.webp style="height: 1em"/>`;
|
||||||
|
const kickKicksIcon = `<img src=icons/badges/kick-kicks.svg style="height: 0.8em"/>`;
|
||||||
|
|
||||||
|
// Render avatars
|
||||||
|
// const avatarURL = await GetAvatar(data.sender.username.replace('_', '-'), 'kick');
|
||||||
|
const avatarURL = `https://files.kick.com/kicks/gifts/${data.gift.gift_id.replace('_', '-')}.webp`;
|
||||||
|
|
||||||
|
UpdateAlertBox(
|
||||||
|
'kick',
|
||||||
|
avatarURL,
|
||||||
|
`${username}`,
|
||||||
|
`sent ${kickKicksIcon} ${data.gift.amount}`,
|
||||||
|
'',
|
||||||
|
username,
|
||||||
|
data.message,
|
||||||
|
kickGiftAction,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async function TikTokGift(data) {
|
async function TikTokGift(data) {
|
||||||
if (!showTikTokGifts)
|
if (!showTikTokGifts)
|
||||||
return;
|
return;
|
||||||
@@ -1710,25 +1745,25 @@ function UpdateAlertBox(platform, avatarURL, headerText, descriptionText, attrib
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GetKickChatroomId(username) {
|
async function GetKickIds(username) {
|
||||||
const url = `https://kick.com/api/v2/channels/${username}`;
|
const url = `https://kick.com/api/v2/channels/${username}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error ${response.status}`);
|
throw new Error(`HTTP error ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.chatroom && data.chatroom.id) {
|
if (data.chatroom && data.chatroom.id) {
|
||||||
return data.chatroom.id;
|
return { chatroomId: data.chatroom.id, channelId: data.chatroom.channel_id };
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Chatroom ID not found in response.");
|
throw new Error("Chatroom ID not found in response.");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch chatroom ID:", error.message);
|
console.error("Failed to fetch chatroom ID:", error.message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GetKickSubBadges(username) {
|
async function GetKickSubBadges(username) {
|
||||||
|
|||||||
@@ -422,6 +422,23 @@
|
|||||||
"showIf": "showKickHosts",
|
"showIf": "showKickHosts",
|
||||||
"group": "Which Kick alerts do you want to see?"
|
"group": "Which Kick alerts do you want to see?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "showKickGifts",
|
||||||
|
"label": "Gifts",
|
||||||
|
"description": "",
|
||||||
|
"type": "checkbox",
|
||||||
|
"defaultValue": true,
|
||||||
|
"group": "Which Kick alerts do you want to see?"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "kickGiftAction",
|
||||||
|
"label": "",
|
||||||
|
"description": "Also run this Streamer.bot Action",
|
||||||
|
"type": "sb-actions",
|
||||||
|
"defaultValue": "",
|
||||||
|
"showIf": "showKickGifts",
|
||||||
|
"group": "Which Kick alerts do you want to see?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "enableTikTokSupport",
|
"id": "enableTikTokSupport",
|
||||||
"label": "Enable TikTok Support",
|
"label": "Enable TikTok Support",
|
||||||
|
|||||||
Reference in New Issue
Block a user