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";
|
import events from "./inc/events";
|
||||||
|
|
||||||
read().then(() => {
|
read().then(() => {
|
||||||
let bot = new wrapper();
|
|
||||||
|
|
||||||
const self = {
|
const self = {
|
||||||
_trigger: new Map(),
|
_trigger: new Map(),
|
||||||
trigger: trigger,
|
trigger: function trigger(args) {
|
||||||
bot: bot
|
|
||||||
};
|
|
||||||
|
|
||||||
triggers.forEach(mod => mod(self));
|
|
||||||
events.forEach(event => event(self));
|
|
||||||
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
logger.error(`(main) ${err.message}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
function trigger(args) {
|
|
||||||
this.call = args.call;
|
this.call = args.call;
|
||||||
this.help = args.help || false;
|
this.help = args.help || false;
|
||||||
this.level = args.level || 0;
|
this.level = args.level || 0;
|
||||||
|
@ -30,4 +16,10 @@ function trigger(args) {
|
||||||
this.set = args.set || "all"; // uwe, nxy, f0ck, all
|
this.set = args.set || "all"; // uwe, nxy, f0ck, all
|
||||||
this.clients = args.clients || ["irc", "tg", "discord"];
|
this.clients = args.clients || ["irc", "tg", "discord"];
|
||||||
this.f = args.f;
|
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 { tg as tglib } from "../clients/tg";
|
||||||
import { discord as discordlib } from "../clients/discord";
|
import { discord as discordlib } from "../clients/discord";
|
||||||
|
|
||||||
import util from "util";
|
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
|
|
||||||
const clients = [];
|
const clients = [];
|
||||||
|
|
||||||
const wrapper = function () {
|
const wrapper = class wrapper extends EventEmitter {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
for (let srv in cfg.client) {
|
for (let srv in cfg.client) {
|
||||||
if(cfg.client[srv].val.enabled) {
|
if(cfg.client[srv].val.enabled) {
|
||||||
switch (cfg.client[srv].val.type) {
|
switch (cfg.client[srv].val.type) {
|
||||||
|
@ -42,7 +43,7 @@ const wrapper = function () {
|
||||||
this.emit(e[0], e[1]);
|
this.emit(e[0], e[1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(wrapper, EventEmitter);
|
|
||||||
export { wrapper, clients };
|
export { wrapper, clients };
|
Loading…
Reference in New Issue
Block a user