1
0
forked from w0bm/f0bm

Initial commit

This commit is contained in:
Flummi
2018-09-02 12:07:40 +02:00
commit 47ccf527ee
30 changed files with 1768 additions and 0 deletions

41
src/inc/wrapper.mjs Normal file
View File

@@ -0,0 +1,41 @@
import { cfg } from "./cfg";
import { irc as irclib } from "../clients/irc";
import { tg as tglib } from "../clients/tg";
import EventEmitter from "events";
const clients = [];
const wrapper = class wrapper extends EventEmitter {
constructor() {
super();
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]);
});
});
}
};
export { wrapper, clients };