modified: src/lib.js

modified:   src/main.js
	modified:   src/trigger/debug.js
	modified:   src/trigger/ytdl.js
This commit is contained in:
Flummi 2016-08-24 21:36:18 +02:00
parent ff9ac383ef
commit b71e20933d
4 changed files with 27 additions and 16 deletions

View File

@ -6,14 +6,14 @@ var probe = require('node-ffprobe');
var crypto = require('crypto');
var Mime = require('mime');
var bot, sql, cfg;
var bot, sql, cfg, debug;
module.exports = Lib;
function Lib(tbot, tsql, tcfg) {
this.bot = bot = tbot;
this.sql = sql = tsql;
this.cfg = cfg = tcfg;
this.debug = true;
this.debug = debug = true;
this.admins = [];
}
@ -177,6 +177,16 @@ Lib.prototype.generateThumbs = () => {
});
};
Lib.prototype.log = (msg) => {
if(this.debug)
if(debug)
bot.send("#f0ck", msg, 'n0xy');
};
Lib.prototype.toggleDebug = () => {
if(debug) {
debug = false;
return 'debugmode deactivated';
}
else {
debug = true;
return 'debugmode activated';
}
};

View File

@ -43,11 +43,15 @@ bot.on('motd', (e) => {
bot.on('message', (e) => {
trigger.trigger.forEach((entry,i,a) => {
if(entry.call.test(e.message) && entry.active == 1) {
lib.log('trigger: '+entry.name);
lib.getUserlevel(e, (cb) => {
if(cb.level >= entry.level)
entry.func(e);
else
e.reply('no permission, min level '+entry.level+' required');
setTimeout(()=>{
if(cb.level >= entry.level) {
entry.func(e);
}
else
e.reply('no permission, min level '+entry.level+' required');
}, 200);
});
}
});

View File

@ -5,14 +5,7 @@ module.exports = (bot, trigger, lib) => {
level: 100,
active: 1,
func: (e) => {
if(lib.debug) {
lib.debug = false;
e.reply('debugmode deactivated');
}
else {
lib.debug = true;
e.reply('debugmode activated');
}
e.reply(lib.toggleDebug());
},
desc: 'toggle debug'
});

View File

@ -19,7 +19,8 @@ module.exports = (bot, trigger, lib) => {
lib.checkRepost(entry, (cbcr) => {
if(cbcr) {
var dat = fs.createWriteStream('./b/'+tmpdest+'.webm');
ytdl(entry, { filter: (format) => { return format.container === 'webm'; } })
//ytdl(entry, { filter: (format) => { return format.container === 'webm'; } })
ytdl(entry)
.on('response', (res) => {
if(res.headers['content-length'] > lib.cfg.maxFileSize) {
res.destroy();
@ -27,6 +28,9 @@ module.exports = (bot, trigger, lib) => {
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 );
dat.on('finish', () => {
if(dl) {