meh
This commit is contained in:
parent
9e29f0c839
commit
984e5a9d24
|
@ -1,56 +0,0 @@
|
|||
exports.lib = (bot, sql) => {
|
||||
return {
|
||||
admins: [],
|
||||
getUser: (u, n, cbgu) => {
|
||||
bot.write('WHOIS '+u, n, () => {
|
||||
bot.once('data', (err, msg) => {
|
||||
var params;
|
||||
var map = [];
|
||||
map.push(u);
|
||||
if(msg.command == 'RPL_WHOISUSER') {
|
||||
params = msg.params.split(' ');
|
||||
map[u] = map[u] || {};
|
||||
map[u].nick = u;
|
||||
map[u].username = params[2];
|
||||
map[u].hostname = params[3];
|
||||
map[u].realname = msg.trailing;
|
||||
}
|
||||
if(typeof(map[u]) === 'object')
|
||||
cbgu(map[u]);
|
||||
});
|
||||
});
|
||||
},
|
||||
getUserlevel: (e, tmp_channel, cb) => {
|
||||
_this.getUser(e.user.getNick(), e.network, (cbgu) => {
|
||||
var host = cbgu.username+'@'+cbgu.hostname;
|
||||
var lvl_channel = (cbgu.nick in tmp_channel)? cfg.level[ tmp_channel[cbgu.nick] ] : 0;
|
||||
var lvl_db = 0;
|
||||
if(host in admins)
|
||||
lvl_db = (admins[host].server == e.network)? admins[host].level : 0;
|
||||
cb({
|
||||
'channel': lvl_channel,
|
||||
'db': lvl_db,
|
||||
'level': Math.max(lvl_channel, lvl_db)
|
||||
});
|
||||
});
|
||||
},
|
||||
loadUser: (cb) => {
|
||||
_this.admins = [];
|
||||
sql.query("select * from `f0ck`.`user`", (err, rows, fields) => {
|
||||
rows.forEach((e,i,a) => {
|
||||
_this.admins.push(e.nick);
|
||||
admins[e.vhost] = {
|
||||
'id': e.id,
|
||||
'nick': e.nick,
|
||||
'vhost': e.vhost,
|
||||
'level': e.level,
|
||||
'server': e.server
|
||||
};
|
||||
});
|
||||
cb(true);
|
||||
}).on('error', () => {
|
||||
cb(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user