import * as db from "./database"; import {config} from "./config"; import {io} from "./http"; import * as irc from "irc"; import * as discord from "discord.js"; import * as twitch from "dank-twitch-irc"; var ircClient; var xmppClient; var twitchClient; var discordClient; var liveUsers: Array; var chatIntegration: Array; async function init() { setInterval(updateUsers, 20000); setInterval(updateInteg, 60000); if(config['chat']['discord']['enabled']){ discordClient = new discord.Client(); discordClient.once('ready', ()=>{ console.log('Discord bot ready')}); discordClient.on('message', (msg) => { if(msg['author']['bot']) return; var lu = getUsr(msg['channel']['name'], 'discord') for(var i=0;i { console.log('IRC Client Error: ', message); }); ircClient.once('registered', () => { console.log("IRC Client Ready"); }); ircClient.on('message', (from, to, msg) => { var lu = getUsr(to, 'irc'); for(var i=0;i { console.log("Twitch Client Ready"); }); twitchClient.on("error", (error) => { if (error != null) { console.error("Twitch Client Error: ", error); } }); twitchClient.on("PRIVMSG", (msg) => { if(msg['senderUserID'] === twitchClient['userStateTracker']['globalState']['userID']) return; var lu = getUsr(msg['channelName'], 'twitch'); for(var i=0;i) { if(channel === null) return; io.to(channel).emit('MSG', {nick: msg[0], msg: msg[1], room: channel}); } function getCh(usr: string, itype: string): string{ for(var i=0;i{ var list: Array = []; for(var i=0;i = []; for(var i=0;i = []; for(var i=0;i