From 7c87736cb33d0a154fbbc5a1817b4e395f391615 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 31 Aug 2016 07:37:41 +0000 Subject: [PATCH] muh --- src/lib.js | 12 ++++++------ src/trigger/parser.js | 4 ++-- src/trigger/ytdl.js | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib.js b/src/lib.js index 961d4bf..c6b5cf6 100644 --- a/src/lib.js +++ b/src/lib.js @@ -88,13 +88,13 @@ Lib.prototype.loadUser = (cb) => { }); } Lib.prototype.checkRepost = (url, cbcr) => { - sql.query("select count(*) as count from `f0ck`.`items` where `src` = ?", url, (err, rows, fields) => { - cbcr((rows[0].count == 0)?true:false); + sql.query("select count(id) as count, id from `f0ck`.`items` where `src` = ?", url, (err, rows, fields) => { + cbcr((rows[0].count == 0)?true:rows[0].id); }); }; Lib.prototype.checkRepostCheckSum = (cs, cbcrcs) => { - sql.query("select count(*) as count from `f0ck`.`items` where `checksum` = ?", cs, (err, rows, fields) => { - cbcrcs((rows[0].count == 0)?true:false); + sql.query("select count(id) as count, id from `f0ck`.`items` where `checksum` = ?", cs, (err, rows, fields) => { + cbcrcs((rows[0].count == 0)?true:rows[0].id); }); }; Lib.prototype.formatSize = (size) => { @@ -117,7 +117,7 @@ Lib.prototype.dl = (url, dest, cb) => { if(cfg.allowedMimes.hasOwnProperty(response.headers['content-type'])) { if(response.headers['content-length'] <= cfg.maxFileSize) { Lib.prototype.checkRepost(url, (cbcr) => { - if(cbcr) { + if(cbcr === true) { var file = fs.createWriteStream(dest+"."+cfg.allowedMimes[response.headers['content-type']]); response.pipe(file); file.on('finish', () => { @@ -145,7 +145,7 @@ Lib.prototype.dl = (url, dest, cb) => { }); } else - cb({'status':false, 'msg':'repost motherf0cker', 'type':1}); + cb({'status':false, 'msg':'repost motherf0cker: https://f0ck.me/'+cbrc, 'type':1}); }); } else diff --git a/src/trigger/parser.js b/src/trigger/parser.js index 2f859dd..d24cf8d 100644 --- a/src/trigger/parser.js +++ b/src/trigger/parser.js @@ -20,7 +20,7 @@ module.exports = (bot, trigger, lib) => { lib.getUser(e, (cbgu) => { lib.getCheckSum("./b/"+tmpdest+"."+cb.infos.ext, (cbcs) => { lib.checkRepostCheckSum(cbcs, (cbcrcs) => { - if(cbcrcs) { + if(cbcrcs === true) { lib.sql.query("insert into `f0ck`.`items` (`src`,`dest`,`mime`,`size`,`checksum`,`username`,`userchannel`,`usernetwork`,`stamp`,`active`) values (?,?,?,?,?,?,?,?,?,?)", [ entry, "./b/"+tmpdest+"."+cb.infos.ext, @@ -41,7 +41,7 @@ module.exports = (bot, trigger, lib) => { } else { fs.unlink("./b/"+tmpdest+"."+cb.infos.ext); // delete repost - e.reply("repost motherf0cker"); + e.reply("repost motherf0cker: https://f0ck.me/"+cbcrcs); } }); }); diff --git a/src/trigger/ytdl.js b/src/trigger/ytdl.js index 956d96b..4b0b39a 100644 --- a/src/trigger/ytdl.js +++ b/src/trigger/ytdl.js @@ -48,7 +48,7 @@ module.exports = (bot, trigger, lib) => { lib.getUser(e, (cbgu) => { lib.getCheckSum("./b/"+tmpdest+".webm", (cbcs) => { lib.checkRepostCheckSum(cbcs, (cbcrcs) => { - if(cbcrcs) { + if(cbcrcs === true) { lib.sql.query("insert into `f0ck`.`items` (`src`,`dest`,`mime`,`size`,`checksum`,`username`,`userchannel`,`usernetwork`,`stamp`,`active`) values (?,?,?,?,?,?,?,?,?,?)", [ entry, "./b/"+tmpdest+".webm", @@ -69,7 +69,7 @@ module.exports = (bot, trigger, lib) => { } else { fs.unlink("./b/"+tmpdest+".webm"); // delete repost - e.reply("repost motherf0cker"); + e.reply("repost motherf0cker: https://f0ck.me/"+cbcrcs); } }); });