fixed whois
This commit is contained in:
parent
611a7e4d61
commit
9911d199e0
110
src/main.js
110
src/main.js
|
@ -63,32 +63,33 @@ bot.on('message', (e) => {
|
||||||
var tmpdest = uuid.v1().split('-')[0];
|
var tmpdest = uuid.v1().split('-')[0];
|
||||||
dl(entry, "./b/"+tmpdest, (cb) => { // download item
|
dl(entry, "./b/"+tmpdest, (cb) => { // download item
|
||||||
if(cb.status === true) {
|
if(cb.status === true) {
|
||||||
var tmpuser = getUser(e.user.getNick(), e.network);
|
getUser(e.user.getNick(), e.network, (cbgu) => {
|
||||||
getCheckSum("./b/"+tmpdest+"."+cb.infos.ext, (cbcs) => {
|
getCheckSum("./b/"+tmpdest+"."+cb.infos.ext, (cbcs) => {
|
||||||
checkRepostCheckSum(cbcs, (cbcrcs) => {
|
checkRepostCheckSum(cbcs, (cbcrcs) => {
|
||||||
if(cbcrcs) {
|
if(cbcrcs) {
|
||||||
sql.query("insert into `f0ck`.`items` (`src`,`dest`,`mime`,`size`,`checksum`,`username`,`userchannel`,`usernetwork`,`stamp`,`active`) values (?,?,?,?,?,?,?,?,?,?)", [
|
sql.query("insert into `f0ck`.`items` (`src`,`dest`,`mime`,`size`,`checksum`,`username`,`userchannel`,`usernetwork`,`stamp`,`active`) values (?,?,?,?,?,?,?,?,?,?)", [
|
||||||
entry,
|
entry,
|
||||||
"./b/"+tmpdest+"."+cb.infos.ext,
|
"./b/"+tmpdest+"."+cb.infos.ext,
|
||||||
cb.infos.mime,
|
cb.infos.mime,
|
||||||
cb.infos.size,
|
cb.infos.size,
|
||||||
cbcs,
|
cbcs,
|
||||||
tmpuser['nick'],
|
cbgu['nick'],
|
||||||
e.channel.getName(),
|
e.channel.getName(),
|
||||||
e.network,
|
e.network,
|
||||||
Math.floor(new Date() / 1000),
|
Math.floor(new Date() / 1000),
|
||||||
0
|
0
|
||||||
]).on('result', (result) => {
|
]).on('result', (result) => {
|
||||||
generateThumbs();
|
generateThumbs();
|
||||||
e.reply("https://f0ck.me/"+result.insertId+" - "+path.parse(entry).base+" ("+cb.infos.mime+", ~"+formatSize(cb.infos.size)+") from "+tmpuser['nick']+" ("+tmpuser['username']+"@"+tmpuser['hostname']+")");
|
e.reply("https://f0ck.me/"+result.insertId+" - "+path.parse(entry).base+" ("+cb.infos.mime+", ~"+formatSize(cb.infos.size)+") from "+cbgu['nick']+" ("+cbgu['username']+"@"+cbgu['hostname']+")");
|
||||||
}).on('error', (msg) => {
|
}).on('error', (msg) => {
|
||||||
e.reply(msg);
|
e.reply(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fs.unlink("./b/"+tmpdest+"."+cb.infos.ext); // delete repost
|
fs.unlink("./b/"+tmpdest+"."+cb.infos.ext); // delete repost
|
||||||
e.reply("repost motherf0cker");
|
e.reply("repost motherf0cker");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -100,8 +101,9 @@ bot.on('message', (e) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(orig.match(/^\.user/)) { // (debug) get userinfos
|
else if(orig.match(/^\.user/)) { // (debug) get userinfos
|
||||||
var tmp = getUser(e.user.getNick(), e.network);
|
getUser(e.user.getNick(), e.network, (cbgu) => {
|
||||||
setTimeout(()=>{ e.reply(tmp); }, 500);
|
e.reply(cbgu);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if(orig.match(/^\!reload tpl$/)) {
|
else if(orig.match(/^\!reload tpl$/)) {
|
||||||
getTpls();
|
getTpls();
|
||||||
|
@ -134,13 +136,13 @@ bot.on('message', (e) => {
|
||||||
}
|
}
|
||||||
else if(orig.match(/^\!level$/)) {
|
else if(orig.match(/^\!level$/)) {
|
||||||
var tmp_channel = bot.getChannel(e.channel.getName(), e.network).names;
|
var tmp_channel = bot.getChannel(e.channel.getName(), e.network).names;
|
||||||
var level = getUserlevel(e, e.user.getNick(), tmp_channel, (cb) => {
|
getUserlevel(e, tmp_channel, (cb) => {
|
||||||
e.reply("level from "+e.user.getNick()+": "+cb.level+" (Channel: "+cb.channel+" DB: "+cb.db+")");
|
e.reply("level from "+e.user.getNick()+": "+cb.level+" (Channel: "+cb.channel+" DB: "+cb.db+")");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if(orig.match(/^\!del (\d+)$/i)) {
|
else if(orig.match(/^\!del (\d+)$/i)) {
|
||||||
var tmp_channel = bot.getChannel(e.channel.getName(), e.network).names;
|
var tmp_channel = bot.getChannel(e.channel.getName(), e.network).names;
|
||||||
getUserlevel(e, e.user.getNick(), tmp_channel, (cb) => {
|
getUserlevel(e, tmp_channel, (cb) => {
|
||||||
if(cb.level >= 100) {
|
if(cb.level >= 100) {
|
||||||
var id = orig.split(' ')[1];
|
var id = orig.split(' ')[1];
|
||||||
sql.query("delete from `f0ck`.`items` where `id` = ?", id).on('end', () => {
|
sql.query("delete from `f0ck`.`items` where `id` = ?", id).on('end', () => {
|
||||||
|
@ -153,7 +155,7 @@ bot.on('message', (e) => {
|
||||||
}
|
}
|
||||||
else if(orig.match(/^\!thumbs$/i)) {
|
else if(orig.match(/^\!thumbs$/i)) {
|
||||||
var tmp_channel = bot.getChannel(e.channel.getName(), e.network).names;
|
var tmp_channel = bot.getChannel(e.channel.getName(), e.network).names;
|
||||||
getUserlevel(e, e.user.getNick(), tmp_channel, (cb) => {
|
getUserlevel(e, tmp_channel, (cb) => {
|
||||||
if(cb.level >= 100) {
|
if(cb.level >= 100) {
|
||||||
//exec('rm ./t/*.png', (error) => {
|
//exec('rm ./t/*.png', (error) => {
|
||||||
e.reply("generating Thumbnails...");
|
e.reply("generating Thumbnails...");
|
||||||
|
@ -166,22 +168,38 @@ bot.on('message', (e) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var getUser = (u, n) => {
|
var getUser = (u, n, cbgu) => {
|
||||||
bot.whois(u, n, (fn)=>{ }); // send whois
|
bot.write('WHOIS '+u, n, () => {
|
||||||
var start = Date.now();
|
bot.once('data', (err, msg) => {
|
||||||
while(Date.now() < start + 500) {} // block script for catch whois
|
var params;
|
||||||
return bot.getUser(u, n);
|
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]);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var getUserlevel = (e, name, tmp_channel, cb) => {
|
var getUserlevel = (e, tmp_channel, cb) => {
|
||||||
var lvl_channel = (name in tmp_channel)? cfg.level[ tmp_channel[name] ] : 0;
|
getUser(e.user.getNick(), e.network, (cbgu) => {
|
||||||
var lvl_db = 0;
|
var host = cbgu.username+'@'+cbgu.hostname;
|
||||||
if(name.toLowerCase() in admins)
|
var lvl_channel = (cbgu.nick in tmp_channel)? cfg.level[ tmp_channel[cbgu.nick] ] : 0;
|
||||||
lvl_db = (admins[name.toLowerCase()].server == e.network)? admins[name.toLowerCase()].level : 0;
|
var lvl_db = 0;
|
||||||
cb({
|
if(host in admins)
|
||||||
'channel': lvl_channel,
|
lvl_db = (admins[host].server == e.network)? admins[host].level : 0;
|
||||||
'db': lvl_db,
|
cb({
|
||||||
'level': Math.max(lvl_channel, lvl_db)
|
'channel': lvl_channel,
|
||||||
|
'db': lvl_db,
|
||||||
|
'level': Math.max(lvl_channel, lvl_db)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,7 +208,7 @@ var loadUser = (cb) => {
|
||||||
sql.query("select * from `f0ck`.`user`", (err, rows, fields) => {
|
sql.query("select * from `f0ck`.`user`", (err, rows, fields) => {
|
||||||
rows.forEach((e,i,a) => {
|
rows.forEach((e,i,a) => {
|
||||||
admins.push(e.nick);
|
admins.push(e.nick);
|
||||||
admins[e.nick] = {
|
admins[e.vhost] = {
|
||||||
'id': e.id,
|
'id': e.id,
|
||||||
'nick': e.nick,
|
'nick': e.nick,
|
||||||
'vhost': e.vhost,
|
'vhost': e.vhost,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user