gtfo chanserv

This commit is contained in:
Flummi 2016-09-14 19:24:48 +02:00
parent 285b97f798
commit 2e4d132963
2 changed files with 31 additions and 0 deletions

21
src/events/join.js Normal file
View File

@ -0,0 +1,21 @@
module.exports = (bot, lib) => {
bot.on('join', (e) => {
bot.whois(e.user.getNick(), e.network, (err, data) => {
if(data.account !== null) {
lib.getUserlevel(e.user.getNick(), e.network, e.channel, (cb) => {
var modes = false;
if(cb.level >= 70)
modes = "+ao";
else if(cb.level >= 60)
modes = "+o";
else if(cb.level >= 50)
modes = "+h";
else if(cb.level >= 10)
modes = "+v";
if(modes !== false)
bot.mode(e.channel, modes + (' '+e.user.getNick()).repeat(modes.length-1), e.network);
});
}
});
});
};

View File

@ -35,6 +35,7 @@ function Lib(tbot, tsql) {
console.log((cb)?"Admins wurden geladen":"Admins konnten nicht geladen werden"); console.log((cb)?"Admins wurden geladen":"Admins konnten nicht geladen werden");
}); });
Lib.prototype.loadTrigger(); Lib.prototype.loadTrigger();
Lib.prototype.loadEvents();
} }
@ -161,3 +162,12 @@ Lib.prototype.loadTrigger = () => {
} }
}); });
}; };
Lib.prototype.loadEvents = () => {
var files = fs.readdirSync(__dirname+'/events/');
files.forEach((file) => {
if(file.substr(-3, 3) === '.js') {
console.log('Loading event', file);
require(__dirname+'/events/' + file)(bot, Lib.prototype);
}
});
};