speed lol
This commit is contained in:
parent
37fc886839
commit
75a700e332
|
@ -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 };
|
||||
|
||||
export { calcSpeed, formatSize, getUUID };
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user