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 crypto = require('crypto');
var Mime = require('mime'); var Mime = require('mime');
var bot, sql, cfg; var bot, sql, cfg, debug;
module.exports = Lib; module.exports = Lib;
function Lib(tbot, tsql, tcfg) { 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 = true; this.debug = debug = true;
this.admins = []; this.admins = [];
} }
@ -177,6 +177,16 @@ Lib.prototype.generateThumbs = () => {
}); });
}; };
Lib.prototype.log = (msg) => { Lib.prototype.log = (msg) => {
if(this.debug) if(debug)
bot.send("#f0ck", msg, 'n0xy'); 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) => { bot.on('message', (e) => {
trigger.trigger.forEach((entry,i,a) => { trigger.trigger.forEach((entry,i,a) => {
if(entry.call.test(e.message) && entry.active == 1) { if(entry.call.test(e.message) && entry.active == 1) {
lib.log('trigger: '+entry.name);
lib.getUserlevel(e, (cb) => { lib.getUserlevel(e, (cb) => {
if(cb.level >= entry.level) setTimeout(()=>{
entry.func(e); if(cb.level >= entry.level) {
else entry.func(e);
e.reply('no permission, min level '+entry.level+' required'); }
else
e.reply('no permission, min level '+entry.level+' required');
}, 200);
}); });
} }
}); });

View File

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

View File

@ -19,7 +19,8 @@ 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'; } }) //ytdl(entry, { filter: (format) => { return format.container === 'webm'; } })
ytdl(entry)
.on('response', (res) => { .on('response', (res) => {
if(res.headers['content-length'] > lib.cfg.maxFileSize) { if(res.headers['content-length'] > lib.cfg.maxFileSize) {
res.destroy(); 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'); 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 ); .pipe( dat );
dat.on('finish', () => { dat.on('finish', () => {
if(dl) { if(dl) {