This commit is contained in:
Flummi 2016-08-24 07:49:17 +00:00
parent c7a48d4fae
commit 91a2edcce7

View File

@ -18,15 +18,23 @@ module.exports = (bot, trigger, lib) => {
lib.checkRepost(entry, (cbcr) => { lib.checkRepost(entry, (cbcr) => {
if(cbcr) { if(cbcr) {
var dat = fs.createWriteStream('./b/'+tmpdest+'.webm'); var dat = fs.createWriteStream('./b/'+tmpdest+'.webm');
ytdl(entry, { filter: (format) => { return format.container === 'webm'; } }) try {
.on('response', (res) => { ytdl(entry, { filter: (format) => { return format.container === 'webm'; } })
if(res.headers['content-length'] > lib.cfg.maxFileSize) { .on('response', (res) => {
res.destroy(); if(res.headers['content-length'] > lib.cfg.maxFileSize) {
dl = false; res.destroy();
e.reply('f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(lib.cfg.maxFileSize)+' allowed'); dl = false;
} e.reply('f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(lib.cfg.maxFileSize)+' allowed');
}) }
.pipe( dat ); })
.pipe( dat );
}
catch(ex) {
dat.close();
fs.unlink('./b/'+tmpdest+'.webm');
e.reply("noep");
dl = false;
}
dat.on('finish', () => { dat.on('finish', () => {
if(dl) { if(dl) {
dat.close(); dat.close();