diff --git a/src/inc/trigger/inc/parser.mjs b/src/inc/trigger/inc/parser.mjs index c5e2a88..76c3f80 100644 --- a/src/inc/trigger/inc/parser.mjs +++ b/src/inc/trigger/inc/parser.mjs @@ -2,5 +2,7 @@ const formatSize = (size, i = ~~(Math.log(size) / Math.log(1024))) => (size / Ma const getUUID = () => Math.random().toString(36).slice(-10) + (new Date()).getTime().toString(36).slice(-3); +const calcSpeed = (bytes, seconds) => `${Math.round((bytes * 8 / seconds / 1000000) * 10000) / 10000} Mbit/s`; -export { formatSize, getUUID }; \ No newline at end of file + +export { calcSpeed, formatSize, getUUID }; \ No newline at end of file diff --git a/src/inc/trigger/parser_new.mjs b/src/inc/trigger/parser_new.mjs index e201f60..76e08c8 100644 --- a/src/inc/trigger/parser_new.mjs +++ b/src/inc/trigger/parser_new.mjs @@ -72,6 +72,7 @@ export default bot => { const uuid = lib.getUUID(); const file = `${b}/${uuid}.${data.format[0].ext}`; const dest = fs.createWriteStream(file); + const start = new Date(); res.body.pipe(dest); let t; dest.on("open", () => { @@ -95,7 +96,9 @@ export default bot => { dest.on("close", blah => { if(t) { clearInterval(t); - e.reply(`gef0ckt lol: ${data.file} -> ${uuid}.${data.format[0].ext}, ~${lib.formatSize(fs.statSync(file).size)}`); + const size = fs.statSync(file).size; + const time = ~~((new Date() - start) / 1000); + e.reply(`gef0ckt lol: ${data.file} -> ${uuid}.${data.format[0].ext}, ~${lib.formatSize(size)}, speed: ${lib.calcSpeed(size, time)}`); } else { // recursive