//Source: https://github.com/tmijs/tmi.js const tmi = require('tmi.js'); const fs = require('fs'); console.log("Starting AutomatedChatLog...") console.log(new Date().toISOString()); var stream = fs.createWriteStream(new Date().toISOString().slice(0,10), {flags:'a'}); const opts = { identity: { username: "UserNameOfBotHere", password: "KeyHere" }, channels: [ "StreamerNameHere" ] }; const client = new tmi.client(opts); client.on('message', onMessageHandler); client.on('connected', onConnectedHandler); client.connect(); let cdate = new Date(); function onMessageHandler (channel, context, msg, self) { cdate = new Date(); console.log(cdate.getHours()+":"+cdate.getMinutes()+" - "+context["display-name"]+" - "+msg); stream.write(cdate.getHours()+":"+cdate.getMinutes()+" - "+context["display-name"]+" - "+msg+"\n") } function onConnectedHandler (addr, port) { console.log(`Connected to ${addr}:${port}`); }