From 2e4d1329637811fa79bd0f63e83e6b731bcaa251 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 14 Sep 2016 19:24:48 +0200 Subject: [PATCH] gtfo chanserv --- src/events/join.js | 21 +++++++++++++++++++++ src/lib.js | 10 ++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/events/join.js diff --git a/src/events/join.js b/src/events/join.js new file mode 100644 index 0000000..2117288 --- /dev/null +++ b/src/events/join.js @@ -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); + }); + } + }); + }); +}; \ No newline at end of file diff --git a/src/lib.js b/src/lib.js index 5099382..6c1e993 100644 --- a/src/lib.js +++ b/src/lib.js @@ -35,6 +35,7 @@ function Lib(tbot, tsql) { console.log((cb)?"Admins wurden geladen":"Admins konnten nicht geladen werden"); }); Lib.prototype.loadTrigger(); + Lib.prototype.loadEvents(); } @@ -160,4 +161,13 @@ Lib.prototype.loadTrigger = () => { require(__dirname+'/trigger/' + file)(bot, Lib.prototype); } }); +}; +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); + } + }); }; \ No newline at end of file