import { cfg } from "./cfg.js"; import { irc as irclib } from "./clients/irc.js"; import { tg as tglib } from "./clients/tg.js"; const util = require("util"); const EventEmitter = require("events").EventEmitter; const clients = []; const wrapper = function () { for (let srv in cfg.client) { if(cfg.client[srv].val.enabled) { switch (cfg.client[srv].val.type) { case "irc": clients.push({ name: cfg.client[srv].val.network, type: "irc", client: new irclib(cfg.client[srv].val) }); break; case "tg": clients.push({ name: "tg", type: "tg", client: new tglib(cfg.client[srv].val) }); break; } } } clients.forEach(client => { client.client.on("data", e => { this.emit(e[0], e[1]); }); }); }; util.inherits(wrapper, EventEmitter); export default { wrapper, clients };