es6 native
This commit is contained in:
40
src/inc/wrapper.mjs
Normal file
40
src/inc/wrapper.mjs
Normal file
@@ -0,0 +1,40 @@
|
||||
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 };
|
Reference in New Issue
Block a user