modified: src/main.js

This commit is contained in:
Flummi 2016-08-15 11:30:27 +02:00
parent 4063ccd706
commit eeb2b04e5b

View File

@ -84,19 +84,6 @@ bot.on('message', (e) => {
var tmp = getUser(e.user.getNick(), e.network);
setTimeout(()=>{ e.reply(tmp); }, 1500);
}
else if(orig.match(/^\.del/) && e.channel.getName() == "#f0ck") {
sql.query("truncate table `f0ck`.`items`")
.on('end', () => {
e.reply("database truncated");
}).on('error', (msg) => {
e.reply(msg);
});
}
else if(orig.match(/^\.hash/) && e.channel.getName() == "#f0ck") {
getCheckSum('./b/1fbd8b80.png', (cbcs) => {
e.reply(cbcs);
});
}
});
var getUser = (u, n) => {
@ -171,6 +158,7 @@ var getCheckSum = (file, cbcs) => {
// Webserver
var handleRequest = (request, response) => {
var tmpres = "";
var url = request.url.split("/")[1];
if(request.url == "/") {
sql.query("select * from `f0ck`.`items`", (err, rows, fields) => {
rows.forEach((e,i,a) => {
@ -178,10 +166,22 @@ var handleRequest = (request, response) => {
});
});
}
else if(Number.isInteger(parseInt(url))) {
sql.query("select * from `f0ck`.`items` where `id` = ? limit 1", url, (err, rows, fields) => {
rows.forEach((e,i,a) => {
tmpres += "ID: "+e.id+"\n";
tmpres += "dest: "+e.dest+"\n";
tmpres += "mime: "+e.mime+"\n";
tmpres += "nick: "+e.username+"\n";
tmpres += "channel: "+e.userchannel+"\n";
tmpres += "network: "+e.usernetwork;
});
});
}
else {
tmpres = "404";
}
setTimeout(()=>{response.end(tmpres);},1000);
setTimeout(()=>{response.end(tmpres);}, 500);
};
var server = http.createServer(handleRequest);