-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwitch.js
More file actions
27 lines (23 loc) · 790 Bytes
/
twitch.js
File metadata and controls
27 lines (23 loc) · 790 Bytes
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
const net = require('net');
const ircMsg = require('irc-message');
const client = net.Socket();
let login = {
server: 'irc.chat.twitch.tv',
port: 6667,
pass: 'oauth:***', //https://twitchapps.com/tmi/ get it here
nick: 'twitch',
channel: 'twitch' //channel you want to watch
}
client.connect(login.port, login.server, () => {
client.write('PASS ' + login.pass + '\r\n');
client.write('NICK ' + login.nick + '\r\n');
client.write('JOIN #' + login.channel + '\r\n');
console.log('listening to channel . . .')
client.on('data', (data) => {
console.log(ircMsg.parse('' + data));
write('channelname', 'message');
});
});
function write(channel, message) {
client.write('PRIVMSG #' + channel + ' : ' + message + '\r\n');
}