-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocket.js
47 lines (36 loc) · 1.34 KB
/
socket.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
40
41
42
43
44
45
46
47
const io = require('socket.io-client');
const player = require('play-sound')(opts = {player: './mplayer-svn-38117/mplayer.exe'})
require('dotenv').config()
const secret = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6IjI2RjUwODVDMzg3RDJDMzgwQTAxIiwicmVhZF9vbmx5Ijp0cnVlLCJwcmV2ZW50X21hc3RlciI6dHJ1ZSwidHdpdGNoX2lkIjoiMTY0MzIzMzgwIn0.Yd4LWt6dy0Xxo1GwEOBoxE0xSLXsbiYBS1LiS5I_vrU'
const streamlabs = io(`https://sockets.streamlabs.com?token=${secret}`, {transports: ['websocket']});
streamlabs.on('connect', () => {
console.log("Connected");
})
streamlabs.on('event', eventData => {
// if (!eventData.for && eventData.type === 'donation') {
// //code to handle donation events
// console.log(eventData.message);
// }
if (eventData.for === 'twitch_account') {
switch(eventData.type) {
case 'donation':
console.log(eventData.message);
case 'follow':
//code to handle follow events
player.play('annoying-siren.mp3', function(err){
if (err) throw err
})
console.log(eventData.message);
break;
case 'subscription':
//code to handle subscription events
console.log(eventData.message);
break;
case 'chat':
console.log(eventData.message);
default:
//default case
console.log(eventData.message);
}
}
})