This commit is contained in:
Flummi 2016-08-30 21:57:09 +00:00
parent 312d3f0769
commit b7abae5f5e

View File

@ -19,65 +19,70 @@ module.exports = (bot, trigger, lib) => {
lib.checkRepost(entry, (cbcr) => {
if(cbcr) {
ytdl.getInfo(entry, (err, info) => {
var title = info.title;
var dat = fs.createWriteStream('./b/'+tmpdest+'.webm');
try {
ytdl.downloadFromInfo(info, { filter: (format) => { return format.container === 'webm'; } })
.on('response', (res) => {
if(res.headers['content-length'] > lib.cfg.maxFileSize) {
res.destroy();
dl = false;
e.reply('f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(lib.cfg.maxFileSize)+' allowed');
}
})
.on('error', (err) => {
//e.reply(err);
})
.pipe( dat );
}
catch(ex) {
e.reply(ex);
}
dat.on('finish', () => {
if(dl) {
dat.close();
var stat = fs.statSync("./b/"+tmpdest+".webm");
lib.getUser(e, (cbgu) => {
lib.getCheckSum("./b/"+tmpdest+".webm", (cbcs) => {
lib.checkRepostCheckSum(cbcs, (cbcrcs) => {
if(cbcrcs) {
lib.sql.query("insert into `f0ck`.`items` (`src`,`dest`,`mime`,`size`,`checksum`,`username`,`userchannel`,`usernetwork`,`stamp`,`active`) values (?,?,?,?,?,?,?,?,?,?)", [
entry,
"./b/"+tmpdest+".webm",
"video/webm",
stat.size,
cbcs,
cbgu['nick'],
e.channel.getName(),
e.network,
Math.floor(new Date() / 1000),
0
]).on('result', (result) => {
lib.generateThumbs();
e.reply("https://f0ck.me/"+result.insertId+" - "+title+" (video/webm, ~"+lib.formatSize(stat.size)+") from "+cbgu['nick']+" ("+cbgu['username']+"@"+cbgu['hostname']+")");
}).on('error', (msg) => {
e.reply(msg);
});
}
else {
fs.unlink("./b/"+tmpdest+".webm"); // delete repost
e.reply("repost motherf0cker");
}
if(!err) {
var title = info.title;
var dat = fs.createWriteStream('./b/'+tmpdest+'.webm');
try {
ytdl.downloadFromInfo(info, { filter: (format) => { return format.container === 'webm'; } })
.on('response', (res) => {
if(res.headers['content-length'] > lib.cfg.maxFileSize) {
res.destroy();
dl = false;
e.reply('f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(lib.cfg.maxFileSize)+' allowed');
}
})
.on('error', (err) => {
//e.reply(err);
})
.pipe( dat );
}
catch(ex) {
e.reply(ex);
}
dat.on('finish', () => {
if(dl) {
dat.close();
var stat = fs.statSync("./b/"+tmpdest+".webm");
lib.getUser(e, (cbgu) => {
lib.getCheckSum("./b/"+tmpdest+".webm", (cbcs) => {
lib.checkRepostCheckSum(cbcs, (cbcrcs) => {
if(cbcrcs) {
lib.sql.query("insert into `f0ck`.`items` (`src`,`dest`,`mime`,`size`,`checksum`,`username`,`userchannel`,`usernetwork`,`stamp`,`active`) values (?,?,?,?,?,?,?,?,?,?)", [
entry,
"./b/"+tmpdest+".webm",
"video/webm",
stat.size,
cbcs,
cbgu['nick'],
e.channel.getName(),
e.network,
Math.floor(new Date() / 1000),
0
]).on('result', (result) => {
lib.generateThumbs();
e.reply("https://f0ck.me/"+result.insertId+" - "+title+" (video/webm, ~"+lib.formatSize(stat.size)+") from "+cbgu['nick']+" ("+cbgu['username']+"@"+cbgu['hostname']+")");
}).on('error', (msg) => {
e.reply(msg);
});
}
else {
fs.unlink("./b/"+tmpdest+".webm"); // delete repost
e.reply("repost motherf0cker");
}
});
});
});
});
}
else
fs.unlink('./b/'+tmpdest+'.webm');
}
else
fs.unlink('./b/'+tmpdest+'.webm');
});
});
});
}
else {
e.reply("f0ck GEMA");
}
}
else
e.reply('repost motherf0cker');