timingproblems fixed
This commit is contained in:
parent
9be8a0a690
commit
ff9ac383ef
12
src/lib.js
12
src/lib.js
|
@ -7,13 +7,13 @@ var crypto = require('crypto');
|
|||
var Mime = require('mime');
|
||||
|
||||
var bot, sql, cfg;
|
||||
var debug = true;
|
||||
|
||||
module.exports = Lib;
|
||||
function Lib(tbot, tsql, tcfg) {
|
||||
this.bot = bot = tbot;
|
||||
this.sql = sql = tsql;
|
||||
this.cfg = cfg = tcfg;
|
||||
this.debug = true;
|
||||
this.admins = [];
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ Lib.prototype.getUser = (e, cbgu) => {
|
|||
var u = e.user.getNick();
|
||||
var n = e.network;
|
||||
if(!e.user.hasOwnProperty('hostname')) {
|
||||
setTimeout(()=>{
|
||||
bot.write('WHOIS '+u, n, () => {
|
||||
bot.once('data', (err, msg) => {
|
||||
var params;
|
||||
|
@ -38,6 +39,7 @@ Lib.prototype.getUser = (e, cbgu) => {
|
|||
cbgu(map[u]);
|
||||
});
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
else {
|
||||
cbgu({
|
||||
|
@ -119,8 +121,8 @@ Lib.prototype.dl = (url, dest, cb) => {
|
|||
if(cfg.allowedMimes.hasOwnProperty(mime)) {
|
||||
probe(dest+"."+cfg.allowedMimes[response.headers['content-type']], (err, probeData) => {
|
||||
if(probeData.streams[0].height !== undefined || probeData.streams[0].width !== undefined) {
|
||||
if(probeData.streams[0].height <= cfg.minRes || probeData.streams[0].width <= cfg.minRes)
|
||||
cb({'status':false, 'msg':'f0ck! your shitpost is too small ('+probeData.streams[0].width+' x '+probeData.streams[0].height+'), min '+cfg.minRes+' x '+cfg.minRes+' required', 'type':1});
|
||||
if(probeData.streams[0].height + probeData.streams[0].width <= cfg.minRes)
|
||||
cb({'status':false, 'msg':'f0ck! your shitpost is too small', 'type':1});
|
||||
else
|
||||
cb({'status':true, 'msg':'downloaded '+dest, 'type':1, 'infos':{'mime':response.headers['content-type'], 'size':response.headers['content-length'], 'ext':cfg.allowedMimes[response.headers['content-type']]}});
|
||||
}
|
||||
|
@ -156,7 +158,7 @@ Lib.prototype.generateThumbs = () => {
|
|||
rows.forEach((e,i,a) => {
|
||||
var thumbnail = outdir+e.id+'.png';
|
||||
if(!fs.existsSync(thumbnail)) {
|
||||
exec('ffmpegthumbnailer -i'+e.dest+' -s256 -o'+thumbnail, (error) => {
|
||||
exec('ffmpegthumbnailer -i'+e.dest+' -s1024 -o'+thumbnail, (error) => {
|
||||
if(error) {
|
||||
Lib.prototype.log('failed thumbnail for '+e.id+' ('+e.mime+') 1');
|
||||
fs.copySync('./s/mp3.png', thumbnail); // copy standardthumbnail
|
||||
|
@ -175,6 +177,6 @@ Lib.prototype.generateThumbs = () => {
|
|||
});
|
||||
};
|
||||
Lib.prototype.log = (msg) => {
|
||||
if(debug)
|
||||
if(this.debug)
|
||||
bot.send("#f0ck", msg, 'n0xy');
|
||||
};
|
19
src/trigger/debug.js
Normal file
19
src/trigger/debug.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
module.exports = (bot, trigger, lib) => {
|
||||
trigger.add({
|
||||
name: 'debug',
|
||||
call: new RegExp('^\\!debug$', 'i'),
|
||||
level: 100,
|
||||
active: 1,
|
||||
func: (e) => {
|
||||
if(lib.debug) {
|
||||
lib.debug = false;
|
||||
e.reply('debugmode deactivated');
|
||||
}
|
||||
else {
|
||||
lib.debug = true;
|
||||
e.reply('debugmode activated');
|
||||
}
|
||||
},
|
||||
desc: 'toggle debug'
|
||||
});
|
||||
};
|
21
src/trigger/thumb.js
Normal file
21
src/trigger/thumb.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
var fs = require('fs-extra');
|
||||
|
||||
module.exports = (bot, trigger, lib) => {
|
||||
trigger.add({
|
||||
name: 'thumbnailer',
|
||||
call: new RegExp('^\\!thumb (\\d+)$', 'i'),
|
||||
level: 100,
|
||||
active: 1,
|
||||
func: (e) => {
|
||||
var id = e.message.split(' ')[1];
|
||||
if(Number.isInteger(parseInt(id))) {
|
||||
fs.unlink('./t/'+id+'.png', () => {
|
||||
//e.reply('debug: Thumbnail gelöscht');
|
||||
lib.generateThumbs();
|
||||
//e.reply('debug: sollte Thumbnail generiert haben');
|
||||
});
|
||||
}
|
||||
},
|
||||
desc: 'regenerate thumbnail'
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user