f0ckv1/src/events/message.js
2016-11-22 07:02:40 +01:00

24 lines
803 B
JavaScript

module.exports = (lib) => {
lib.bot.on('message', (e) => {
lib.trigger.trigger.forEach((entry,i,a) => {
if(e.message.match(entry.call)) {
let active = false;
if(lib.cfg.trigger[e.network+e.channel.getName()] !== undefined) {
if(lib.cfg.trigger[e.network+e.channel.getName()][entry.name])
active = true;
}
else
active = entry.active;
if(active) {
lib.log('trigger: '+entry.name);
lib.getUserlevel(e.user.getNick(), e.network, e.channel.getName(), (cb) => {
if(cb.level >= entry.level)
entry.func(e, cb.level);
else
e.reply('no permission, min level '+entry.level+' required');
});
}
}
});
});
};