fixed channelnames

This commit is contained in:
Flummi 2016-09-09 08:32:35 +00:00
parent a98395ac2c
commit d5f99d1293
4 changed files with 12 additions and 12 deletions

View File

@ -25,7 +25,8 @@ Lib.prototype.debug = false;
Lib.prototype.getUserlevel = (user, network, channel, cb) => { Lib.prototype.getUserlevel = (user, network, channel, cb) => {
bot.whois(user, network, (err, data) => { bot.whois(user, network, (err, data) => {
var host = data.username+'@'+data.hostname; var host = data.username+'@'+data.hostname;
var lvl_channel = (data.nick in channel)? cfg.level[ channel[data.nick] ] : 0; bot.names(channel, network, (names) => {
var lvl_channel = (data.nick in names)? cfg.level[ names[data.nick] ] : 0;
var lvl_db = 0; var lvl_db = 0;
if(host in Lib.prototype.admins) if(host in Lib.prototype.admins)
lvl_db = (Lib.prototype.admins[host].server == network)? Lib.prototype.admins[host].level : 0; lvl_db = (Lib.prototype.admins[host].server == network)? Lib.prototype.admins[host].level : 0;
@ -35,6 +36,7 @@ Lib.prototype.getUserlevel = (user, network, channel, cb) => {
'level': Math.max(lvl_channel, lvl_db) 'level': Math.max(lvl_channel, lvl_db)
}); });
}); });
});
}; };
Lib.prototype.loadUser = (cb) => { Lib.prototype.loadUser = (cb) => {
Lib.prototype.admins = []; Lib.prototype.admins = [];

View File

@ -44,7 +44,7 @@ bot.on('message', (e) => {
trigger.trigger.forEach((entry,i,a) => { trigger.trigger.forEach((entry,i,a) => {
if(e.message.match(entry.call) && entry.active == 1) { if(e.message.match(entry.call) && entry.active == 1) {
lib.log('trigger: '+entry.name); lib.log('trigger: '+entry.name);
lib.getUserlevel(e.user.getNick(), e.network, e.channel.names, (cb) => { lib.getUserlevel(e.user.getNick(), e.network, e.channel.getName(), (cb) => {
if(cb.level >= entry.level) if(cb.level >= entry.level)
entry.func(e, cb.level); entry.func(e, cb.level);
else else

View File

@ -49,7 +49,7 @@ module.exports = (bot, trigger, lib) => {
user = e.user.getNick(); user = e.user.getNick();
else else
user = user.trim(); user = user.trim();
lib.getUserlevel(user, e.network, e.channel.names, cb => { lib.getUserlevel(user, e.network, e.channel.getName(), cb => {
e.reply("level from "+user+": "+cb.level+" (Channel: "+cb.channel+" DB: "+cb.db+")"); e.reply("level from "+user+": "+cb.level+" (Channel: "+cb.channel+" DB: "+cb.db+")");
}); });
} }

View File

@ -76,8 +76,6 @@ module.exports = (bot, trigger, lib) => {
else else
e.reply('f0ck! your file is too big (~'+lib.formatSize(length)+'), max '+lib.formatSize(cfg.maxFileSize)+' allowed'); e.reply('f0ck! your file is too big (~'+lib.formatSize(length)+'), max '+lib.formatSize(cfg.maxFileSize)+' allowed');
} }
else
e.reply('lol, go f0ck yourself');
} }
}); });
} }