-
Notifications
You must be signed in to change notification settings - Fork 0
/
odysee_chat_logger.js
39 lines (30 loc) · 1006 Bytes
/
odysee_chat_logger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const WebSocket = require("ws");
const link = "insert wss-url here";
const chat = new WebSocket(link);
chat.on("error", console.error);
chat.addEventListener('open', function (event) {
console.log("ODYSEE IS CONNECTED")
});
chat.addEventListener('message', function (event) {
let comment=JSON.parse(event.data);
let msg = comment.data.comment?.comment;
let channel_name = comment.data.comment?.channel_name;
let nickname = channel_name?.substring(1);
let credits = comment.data.comment?.support_amount;
/// VIEWERS COUNT
if (comment.type === 'viewers') {
return console.log(`[Odysee | Current Viewers : ${comment.data.connected} ]`)
}
/// CHAT LOG
if (comment.type === 'delta') {
console.log(`[Odysee | ${nickname}] ${msg}`)
/// SUPPORT EVENT - LBC CREDITS
if (credits > 0) {
console.log(`[Odysee]: ${nickname} gives ${credits} LBC`)
}
}
});
chat.on("close", () => {
console.log("ODYSEE IS DISCONNECTED");
process.exit(0);
});