40 lines
891 B
JavaScript
40 lines
891 B
JavaScript
import { cfg } from "./cfg";
|
|
import { irc as irclib } from "../clients/irc";
|
|
import { tg as tglib } from "../clients/tg";
|
|
|
|
import util from "util";
|
|
import EventEmitter from "events";
|
|
|
|
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 { wrapper, clients }; |