Update module.js

This commit is contained in:
Rodrigo Emanuel
2025-05-11 02:59:58 -03:00
committed by GitHub
parent 29ba20fde0
commit 41ce0aa8fa

View File

@@ -13,105 +13,112 @@ const kick7TVEmojis = new Map();
if (showKickViewers == false) { document.querySelector('#statistics #kick').style.display = 'none'; } if (showKickViewers == false) { document.querySelector('#statistics #kick').style.display = 'none'; }
if (kickUserName) {
const kickWebSocket = new WebSocket( const kickWebSocket = new WebSocket(
`wss://ws-us2.pusher.com/app/32cbd69e4b950bf97679?protocol=7&client=js&version=8.4.0-rc2&flash=false` `wss://ws-us2.pusher.com/app/32cbd69e4b950bf97679?protocol=7&client=js&version=8.4.0-rc2&flash=false`
); );
kickWebSocket.onerror = (error) => { kickWebSocket.onerror = (error) => {
console.error("Kick WebSocket Error: " + error); console.error("Kick WebSocket Error: " + error);
}; };
kickWebSocket.onopen = () => { kickWebSocket.onopen = () => {
kickGetUserInfo(kickUserName) kickGetUserInfo(kickUserName)
.then((userInfo) => { .then((userInfo) => {
console.log('Got Kick User Info', userInfo); console.log('Got Kick User Info', userInfo);
(async () => { (async () => {
const kick7TVEmotes = await get7TVEmotes(userInfo.user_id); const kick7TVEmotes = await get7TVEmotes(userInfo.user_id);
if (kick7TVEmotes != null) { if (kick7TVEmotes != null) {
console.debug("Getting all Kick's 7TV Emojis + Globals", kick7TVEmotes); console.debug("Getting all Kick's 7TV Emojis + Globals", kick7TVEmotes);
kick7TVEmotes.forEach(emote => { kick7TVEmotes.forEach(emote => {
kick7TVEmojis.set(emote.name, emote.url); kick7TVEmojis.set(emote.name, emote.url);
}); });
} }
})(); })();
kickWebSocket.send(
JSON.stringify({
event: "pusher:subscribe",
data: {
auth: null,
channel: `chatrooms.${userInfo.chatroom.id}.v2`
},
})
);
kickWebSocket.send(
JSON.stringify({
event: "pusher:subscribe",
data: {
auth: null,
channel: `channel.${userInfo.chatroom.channel_id}`
},
})
);
setInterval(() => {
kickWebSocket.send( kickWebSocket.send(
JSON.stringify({ JSON.stringify({
event: "pusher:ping", event: "pusher:subscribe",
data: {}, data: {
auth: null,
channel: `chatrooms.${userInfo.chatroom.id}.v2`
},
}) })
); );
}, 60000);
kickUpdateStatistics(userInfo); kickWebSocket.send(
setInterval(() => { JSON.stringify({
kickGetUserInfo(kickUserName) event: "pusher:subscribe",
.then((data) =>{ data: {
kickUpdateStatistics(data); auth: null,
}); channel: `channel.${userInfo.chatroom.channel_id}`
}, 15000); },
})
);
setInterval(() => {
kickWebSocket.send(
JSON.stringify({
event: "pusher:ping",
data: {},
})
);
}, 60000);
kickUpdateStatistics(userInfo);
setInterval(() => {
kickGetUserInfo(kickUserName)
.then((data) =>{
kickUpdateStatistics(data);
});
}, 15000);
}); });
}; };
kickWebSocket.onmessage = async ({ data }) => { kickWebSocket.onmessage = async ({ data }) => {
const parsed = JSON.parse(data); const parsed = JSON.parse(data);
const json = JSON.parse(parsed.data); const json = JSON.parse(parsed.data);
if (!parsed.event.includes("pusher")) { if (!parsed.event.includes("pusher")) {
switch (parsed.event) { switch (parsed.event) {
case "App\\Events\\ChatMessageEvent": case "App\\Events\\ChatMessageEvent":
console.debug('Kick Chat', json); console.debug('Kick Chat', json);
kickChatMessage(json); kickChatMessage(json);
break; break;
case "App\\Events\\MessageDeletedEvent": case "App\\Events\\MessageDeletedEvent":
kickChatMessageDeleted(json); kickChatMessageDeleted(json);
break; break;
case "App\\Events\\UserBannedEvent": case "App\\Events\\UserBannedEvent":
kickUserBanned(json); kickUserBanned(json);
break; break;
case "App\\Events\\ChatroomClearEvent": case "App\\Events\\ChatroomClearEvent":
kickChatClearMessages() kickChatClearMessages()
break; break;
default:
console.debug('Kick Event From WebSocket', parsed.event, json);
}
default:
console.debug('Kick Event From WebSocket', parsed.event, json);
} }
};
}
else {
console.debug('Kick User not set in ChatRD');
}
}
};
streamerBotClient.on('General.Custom', (response) => { streamerBotClient.on('General.Custom', (response) => {