This commit is contained in:
Flummi 2016-08-24 22:21:02 +02:00
parent 649e4339aa
commit 2fbffc0574
2 changed files with 37 additions and 35 deletions

View File

@ -13,7 +13,7 @@ function Lib(tbot, tsql, tcfg) {
this.bot = bot = tbot; this.bot = bot = tbot;
this.sql = sql = tsql; this.sql = sql = tsql;
this.cfg = cfg = tcfg; this.cfg = cfg = tcfg;
this.debug = debug = true; this.debug = debug = false;
this.admins = []; this.admins = [];
} }

View File

@ -14,42 +14,44 @@ module.exports = (bot, trigger, lib) => {
var tmp = e.message.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi); // get links var tmp = e.message.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi); // get links
tmp.forEach((entry,i,a) => { tmp.forEach((entry,i,a) => {
var tmpdest = uuid.v1().split('-')[0]; var tmpdest = uuid.v1().split('-')[0];
lib.dl(entry, "./b/"+tmpdest, (cb) => { // download item if(!entry.match(/f0ck\.me/i)) {
if(cb.status === true) { lib.dl(entry, "./b/"+tmpdest, (cb) => { // download item
lib.getUser(e, (cbgu) => { if(cb.status === true) {
lib.getCheckSum("./b/"+tmpdest+"."+cb.infos.ext, (cbcs) => { lib.getUser(e, (cbgu) => {
lib.checkRepostCheckSum(cbcs, (cbcrcs) => { lib.getCheckSum("./b/"+tmpdest+"."+cb.infos.ext, (cbcs) => {
if(cbcrcs) { lib.checkRepostCheckSum(cbcs, (cbcrcs) => {
lib.sql.query("insert into `f0ck`.`items` (`src`,`dest`,`mime`,`size`,`checksum`,`username`,`userchannel`,`usernetwork`,`stamp`,`active`) values (?,?,?,?,?,?,?,?,?,?)", [ if(cbcrcs) {
entry, lib.sql.query("insert into `f0ck`.`items` (`src`,`dest`,`mime`,`size`,`checksum`,`username`,`userchannel`,`usernetwork`,`stamp`,`active`) values (?,?,?,?,?,?,?,?,?,?)", [
"./b/"+tmpdest+"."+cb.infos.ext, entry,
cb.infos.mime, "./b/"+tmpdest+"."+cb.infos.ext,
cb.infos.size, cb.infos.mime,
cbcs, cb.infos.size,
cbgu['nick'], cbcs,
e.channel.getName(), cbgu['nick'],
e.network, e.channel.getName(),
Math.floor(new Date() / 1000), e.network,
0 Math.floor(new Date() / 1000),
]).on('result', (result) => { 0
lib.generateThumbs(); ]).on('result', (result) => {
e.reply("https://f0ck.me/"+result.insertId+" - "+path.parse(entry).base+" ("+cb.infos.mime+", ~"+lib.formatSize(cb.infos.size)+") from "+cbgu['nick']+" ("+cbgu['username']+"@"+cbgu['hostname']+")"); lib.generateThumbs();
}).on('error', (msg) => { e.reply("https://f0ck.me/"+result.insertId+" - "+path.parse(entry).base+" ("+cb.infos.mime+", ~"+lib.formatSize(cb.infos.size)+") from "+cbgu['nick']+" ("+cbgu['username']+"@"+cbgu['hostname']+")");
e.reply(msg); }).on('error', (msg) => {
}); e.reply(msg);
} });
else { }
fs.unlink("./b/"+tmpdest+"."+cb.infos.ext); // delete repost else {
e.reply("repost motherf0cker"); fs.unlink("./b/"+tmpdest+"."+cb.infos.ext); // delete repost
} e.reply("repost motherf0cker");
}
});
}); });
}); });
}); }
} else
else if(cb.type == 1)
if(cb.type == 1) e.reply(cb.msg);
e.reply(cb.msg); });
}); }
}); });
} }
} }