2016-09-14 22:05:18 +00:00
|
|
|
module.exports = (lib) => {
|
|
|
|
lib.bot.on('message', (e) => {
|
|
|
|
lib.trigger.trigger.forEach((entry,i,a) => {
|
2016-11-19 05:33:59 +00:00
|
|
|
if(e.message.match(entry.call)) {
|
|
|
|
let active = false;
|
|
|
|
if(lib.trigger.chans[e.network+e.channel.getName()] !== undefined) {
|
|
|
|
if(lib.trigger.chans[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');
|
|
|
|
});
|
|
|
|
}
|
2016-09-14 22:05:18 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|