Created
March 1, 2025 16:23
-
-
Save Linch1/861902c8a85977b4dbcb562966b65bed to your computer and use it in GitHub Desktop.
Listen Kick.com chat directly from socket connection. TO-DO: automatically CHAT_ROOM detection using the commented request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import WebSocket from 'ws'; | |
import axios from "axios"; | |
let URL = "wss://ws-us2.pusher.com/app/32cbd69e4b950bf97679?protocol=7&client=js&version=8.4.0-rc2&flash=false" | |
/* | |
from this request you can get the CHAT_ROOM from the username | |
let USER = "santamaria" | |
let response = await axios.get(`https://kick.com/api/v2/channels/${USER}/chatroom`, { | |
headers: { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0' | |
} | |
}); | |
console.log(response.data.id); */ | |
let CHAT_ROOM = 79873 /* how to get this? see the commented request above*/ | |
const ws = new WebSocket(URL); | |
ws.on('error', console.error); | |
ws.on('open', function open() { | |
ws.send(JSON.stringify({"event":"pusher:subscribe","data":{"auth":"","channel":`chatrooms.${CHAT_ROOM}.v2`}})); | |
ws.send(JSON.stringify({"event":"pusher:subscribe","data":{"auth":"","channel":`chatroom_${CHAT_ROOM}`}})); | |
ws.send(JSON.stringify({"event":"pusher:subscribe","data":{"auth":"","channel":`chatrooms.${CHAT_ROOM}`}})); | |
}); | |
ws.on('message', function message(data) { | |
console.log('received: %s', data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment