es6ify
This commit is contained in:
parent
95d76163e3
commit
a225922753
24
src/bot.mjs
24
src/bot.mjs
|
@ -6,23 +6,9 @@ import triggers from "./inc/trigger";
|
|||
import events from "./inc/events";
|
||||
|
||||
read().then(() => {
|
||||
let bot = new wrapper();
|
||||
|
||||
const self = {
|
||||
_trigger: new Map(),
|
||||
trigger: trigger,
|
||||
bot: bot
|
||||
};
|
||||
|
||||
triggers.forEach(mod => mod(self));
|
||||
events.forEach(event => event(self));
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
logger.error(`(main) ${err.message}`);
|
||||
});
|
||||
|
||||
function trigger(args) {
|
||||
trigger: function trigger(args) {
|
||||
this.call = args.call;
|
||||
this.help = args.help || false;
|
||||
this.level = args.level || 0;
|
||||
|
@ -30,4 +16,10 @@ function trigger(args) {
|
|||
this.set = args.set || "all"; // uwe, nxy, f0ck, all
|
||||
this.clients = args.clients || ["irc", "tg", "discord"];
|
||||
this.f = args.f;
|
||||
}
|
||||
},
|
||||
bot: new wrapper()
|
||||
};
|
||||
|
||||
triggers.forEach(mod => mod(self));
|
||||
events.forEach(event => event(self));
|
||||
}).catch(err => logger.error(`(main) ${err.message}`));
|
||||
|
|
|
@ -3,12 +3,13 @@ import { irc as irclib } from "../clients/irc";
|
|||
import { tg as tglib } from "../clients/tg";
|
||||
import { discord as discordlib } from "../clients/discord";
|
||||
|
||||
import util from "util";
|
||||
import EventEmitter from "events";
|
||||
|
||||
const clients = [];
|
||||
|
||||
const wrapper = function () {
|
||||
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) {
|
||||
|
@ -42,7 +43,7 @@ const wrapper = function () {
|
|||
this.emit(e[0], e[1]);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
util.inherits(wrapper, EventEmitter);
|
||||
export { wrapper, clients };
|
Loading…
Reference in New Issue
Block a user