Uwev2/src/bot.mjs

33 lines
786 B
JavaScript
Raw Normal View History

2017-12-04 11:22:53 +00:00
import { logger } from "./inc/log";
import { read, cfg } from "./inc/cfg";
import { wrapper } from "./inc/wrapper";
2018-03-01 05:45:26 +00:00
import triggers from "./inc/trigger";
import events from "./inc/events";
2017-11-07 17:22:41 +00:00
read().then(() => {
2017-11-08 11:56:04 +00:00
let bot = new wrapper();
2017-11-20 16:30:20 +00:00
const self = {
2017-11-26 23:00:54 +00:00
_trigger: new Map(),
2018-03-01 05:45:26 +00:00
trigger: trigger,
bot: bot
2017-11-20 16:30:20 +00:00
};
2017-12-04 13:59:42 +00:00
triggers.forEach(mod => mod(self));
2018-03-01 05:45:26 +00:00
events.forEach(event => event(self));
2017-11-28 01:27:25 +00:00
})
.catch(err => {
2017-12-03 16:55:36 +00:00
logger.error(`(main) ${err.message}`);
2017-11-26 23:00:54 +00:00
});
2017-11-26 23:09:41 +00:00
function trigger(args) {
2017-11-26 23:00:54 +00:00
this.call = args.call;
2017-12-04 16:40:24 +00:00
this.help = args.help || false;
2017-11-26 23:00:54 +00:00
this.level = args.level || 0;
2017-11-26 23:09:41 +00:00
this.active = args.hasOwnProperty("active") ? args.active : true;
2018-02-28 03:34:52 +00:00
this.set = args.set || "all"; // uwe, nxy, f0ck, all
2018-02-27 08:24:32 +00:00
this.clients = args.clients || ["irc", "tg", "discord"];
2017-11-26 23:00:54 +00:00
this.f = args.f;
2018-03-01 05:45:26 +00:00
}