import { cfg, read } from './cfg.js'; import { loadEvents } from './lib.js'; let irclib = require('./clients/irc.js'); let tglib = require('./clients/tg.js') //let tglib = require('node-telegram-bot-api'); //const safeEval = require('safe-eval'); const util = require('util'); //const fs = require('fs'); //const ytdl = util.promisify(require('youtube-dl').getInfo); var EventEmitter = require('events').EventEmitter; let clients = []; const wrapper = function() { for(let srv in cfg.client) { switch(cfg.client[srv].type) { case "irc": clients.push({ name: cfg.client[srv].network, type: "irc", client: new irclib(cfg.client[srv]) }); break; case "tg": clients.push({ name: "tg", type: "tg", client: new tglib(cfg.client[srv]) }); break; } } clients.forEach(client => { client.client.on("message", e => { this.emit('message', e); }); }); }; util.inherits(wrapper, EventEmitter); export default { wrapper, clients };