You can use the tmi.js module to automatically handle parsing every message.
const tmi = require('tmi.js');
let client = new tmi.client({
options: {
debug: true
},
connection: {
reconnect: true
},
identity: {
username: 'username',
password: 'oauth token'
},
channels: [ 'alca' ]
});
client.on('connected', (addr, port) => {
console.log(`Connected via ${addr}:${port}`);
});
client.on('clearchat', channel => {
console.log('Chat cleared in', channel);
});
/* etc. -- https://docs.tmijs.org/v1.1.1/Events.html */
client.connect();
It makes developing for the Twitch Message Interface with Javascript much faster and more simple.