Merge branch 'f0ckdev' into 'master'
maxfilesize * 2 for Admins See merge request !87
This commit is contained in:
commit
be37a79908
|
@ -20,7 +20,7 @@ module.exports = (lib) => {
|
|||
var tmp = e.message.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi); // get links
|
||||
tmp.forEach((entry,i,a) => {
|
||||
if(!entry.match(/f0ck\.me/i) && !entry.match(/\.onion/i)) {
|
||||
getLink(entry, ((e.message.match(/(!|-)force/i) && userlevel >= 100)?true:false), (e.message.match(/(!|-)audio/i)?true:false), (cb) => {
|
||||
getLink(entry, ((e.message.match(/(!|-)force/i) && userlevel >= 100)?true:false), userlevel, (cb) => {
|
||||
if(cb.success === true) {
|
||||
fs.move(cb.file, cb.file + '.' + cb.info.ext, (err) => {
|
||||
if(!err) {
|
||||
|
@ -64,7 +64,7 @@ module.exports = (lib) => {
|
|||
desc: 'muh'
|
||||
});
|
||||
|
||||
var getLink = (url, force, m4a, cb) => {
|
||||
var getLink = (url, force, userlevel, cb) => {
|
||||
var yt = /https?:\/\/(www\.)?youtu(\.be\/|be\.com\/)((.+\/)?(watch(\?v=|.+&v=))?(v=)?)([\w_-]{11})(&.+)?/gi;
|
||||
var sc = /https?:\/\/(www\.)?(soundcloud\.com|snd\.sc)(\/\S*)(\/\S*)/gi;
|
||||
lib.checkRepost(url, (cbcr) => {
|
||||
|
@ -78,28 +78,22 @@ module.exports = (lib) => {
|
|||
var title = inf.title;
|
||||
var iurl = inf.iurl;
|
||||
try {
|
||||
//var dlformat = (m4a?'audioonly':'webm');
|
||||
var dlformat;
|
||||
if(m4a)
|
||||
dlformat = { format: '171' };
|
||||
else
|
||||
dlformat = { filter: (format) => { return format.container === 'webm'; } };
|
||||
|
||||
ytdl.downloadFromInfo(inf, dlformat)
|
||||
.on('response', (res) => {
|
||||
if( ( res.headers['content-length'] <= lib.cfg.main.maxFileSize ) || force ) {
|
||||
if( ( res.headers['content-length'] <= lib.cfg.main.maxFileSize ) || force || ( userlevel >= 70 && res.headers['content-length'] <= (lib.cfg.main.maxFileSize * 2) ) ) {
|
||||
info = {
|
||||
type: 'youtube',
|
||||
title: title,
|
||||
mime: (m4a?'audio/mpeg':'video/webm'),
|
||||
ext: (m4a?'mp3':'webm'),
|
||||
mime: 'video/webm',
|
||||
ext: 'webm',
|
||||
thumb: iurl
|
||||
};
|
||||
}
|
||||
else {
|
||||
res.destroy();
|
||||
dat.end();
|
||||
cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize(lib.cfg.main.maxFileSize)+' allowed' });
|
||||
cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(res.headers['content-length'])+'), max '+lib.formatSize( ( userlevel >= 70?(lib.cfg.main.maxFileSize*2):lib.cfg.main.maxFileSize ) )+' allowed' });
|
||||
}
|
||||
})
|
||||
.on('error', (err) => {
|
||||
|
@ -145,10 +139,9 @@ module.exports = (lib) => {
|
|||
if(!err) {
|
||||
var type = res.headers['content-type'];
|
||||
lib.log('MimeType: '+type);
|
||||
var length = res.headers['content-length'];
|
||||
if(lib.cfg.main.allowedMimes.hasOwnProperty(type)) {
|
||||
if( ( data.length <= lib.cfg.main.maxFileSize ) || force ) {
|
||||
var s = new Readable
|
||||
if( ( data.length <= lib.cfg.main.maxFileSize ) || force || ( userlevel >= 70 && data.length <= (lib.cfg.main.maxFileSize * 2) ) ) {
|
||||
var s = new Readable;
|
||||
s.push(data);
|
||||
s.push(null);
|
||||
s.pipe(dat);
|
||||
|
@ -162,7 +155,7 @@ module.exports = (lib) => {
|
|||
}
|
||||
else {
|
||||
dat.end();
|
||||
cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(data.length)+'), max '+lib.formatSize(lib.cfg.main.maxFileSize)+' allowed' });
|
||||
cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(data.length)+'), max '+lib.formatSize( ( userlevel >= 70?(lib.cfg.main.maxFileSize*2):lib.cfg.main.maxFileSize ) )+' allowed' });
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -181,7 +174,7 @@ module.exports = (lib) => {
|
|||
.on('finish', () => {
|
||||
var size = dat.bytesWritten;
|
||||
dat.end();
|
||||
if( ( size <= lib.cfg.main.maxFileSize ) || force ) {
|
||||
if( ( size <= lib.cfg.main.maxFileSize ) || force || ( userlevel >= 70 && size <= (lib.cfg.main.maxFileSize * 2) ) ) {
|
||||
fs.stat('./b/' + tmpdest, (err, stat) => {
|
||||
if(!err && stat.isFile() && stat.size > 300) {
|
||||
lib.log('Datei '+tmpdest+' existiert');
|
||||
|
@ -204,7 +197,7 @@ module.exports = (lib) => {
|
|||
});
|
||||
}
|
||||
else {
|
||||
cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(size)+'), max '+lib.formatSize(lib.cfg.main.maxFileSize)+' allowed' });
|
||||
cb({ success: false, file: tmpdest, msg: 'f0ck! your file is too big (~'+lib.formatSize(size)+'), max '+lib.formatSize( ( userlevel >= 70?(lib.cfg.main.maxFileSize*2):lib.cfg.main.maxFileSize ) )+' allowed' });
|
||||
}
|
||||
})
|
||||
.on('error', (err) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user