modified: src/main.js

This commit is contained in:
Flummi 2016-08-14 16:54:37 +02:00
parent 93653c5e53
commit 97bf115120

View File

@ -66,7 +66,7 @@ bot.on('message', (e) => {
tmpuser['nick'],
e.channel.getName(),
e.network,
new Date().getTime(),
Math.floor(new Date() / 1000),
0
]).on('result', (result) => {
@ -108,41 +108,37 @@ var getUser = (u, n) => {
};
var dl = (url, dest, cb) => {
var request = (url.match(/^https/)?https:http).get(url, (response) => {
try { // type:1=post,type:2=stfu
console.log(response.headers['content-type']);
if(allowed.indexOf(response.headers['content-type']) != -1) {
if(response.headers['content-length'] <= maxFileSize) {
checkRepost(url, (cbcr) => {
if(cbcr) {
var file = fs.createWriteStream(dest);
response.pipe(file);
file.on('finish', () => {
file.close();
cb({'status':true, 'msg':'downloaded '+dest, 'type':1, 'infos':{'mime':response.headers['content-type'], 'size':response.headers['content-length']}});
});
file.on('error', (err) => {
fs.unlink(dest);
file.close();
cb({'status':false, 'msg':err.message, 'type':1});
});
}
else {
cb({'status':false, 'msg':'repost motherf0cker', 'type':1});
}
});
}
else {
cb({'status':false, 'msg':'f0ck! your file is too big (~'+formatSize(response.headers['content-length'])+'), max '+formatSize(maxFileSize)+' allowed', 'type':1});
}
var request = (url.match(/^https/)?https:http).get(url, (response) => { // type:1=post,type:2=stfu
if(allowed.indexOf(response.headers['content-type']) != -1) {
if(response.headers['content-length'] <= maxFileSize) {
checkRepost(url, (cbcr) => {
if(cbcr) {
var file = fs.createWriteStream(dest);
response.pipe(file);
file.on('finish', () => {
file.close();
cb({'status':true, 'msg':'downloaded '+dest, 'type':1, 'infos':{'mime':response.headers['content-type'], 'size':response.headers['content-length']}});
});
file.on('error', (err) => {
fs.unlink(dest);
file.close();
cb({'status':false, 'msg':err.message, 'type':1});
});
}
else {
cb({'status':false, 'msg':'repost motherf0cker', 'type':1});
}
});
}
else {
cb({'status':false, 'msg':'f0ck you', 'type':2});
cb({'status':false, 'msg':'f0ck! your file is too big (~'+formatSize(response.headers['content-length'])+'), max '+formatSize(maxFileSize)+' allowed', 'type':1});
}
}
catch(ex) {
e.reply(ex);
else {
cb({'status':false, 'msg':'f0ck you', 'type':2});
}
}).on('error', (msg) => {
cb({'status':false, 'msg':msg, 'type':2});
});
};