From 222ecf1d765e8cdaf07d7ea0c432dca1f6ba1657 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Wed, 7 Dec 2022 13:56:22 -0500 Subject: [PATCH] Adding Basic Functions, Generate --- cache/1600528742396399616 | 1 + index.mjs | 418 +++++++++++++++++++++++- orders_generated.log | 27 ++ package-lock.json | 650 ++++++++++++++++++++++++++++++++++++++ package.json | 7 +- show.js | 491 ++++++++++++++++++++++++++++ 6 files changed, 1585 insertions(+), 9 deletions(-) create mode 100644 cache/1600528742396399616 create mode 100644 orders_generated.log create mode 100644 show.js diff --git a/cache/1600528742396399616 b/cache/1600528742396399616 new file mode 100644 index 0000000..757e751 --- /dev/null +++ b/cache/1600528742396399616 @@ -0,0 +1 @@ +{"pwd":"/"} \ No newline at end of file diff --git a/index.mjs b/index.mjs index 1558e33..a1eb35d 100644 --- a/index.mjs +++ b/index.mjs @@ -2,8 +2,22 @@ import { Client } from "twitter-api-sdk"; import Twit from "twit"; import dotenv from "dotenv"; dotenv.config(); -import { Configuration, OpenAIApi } from "openai"; -import fs from "fs/promises"; +import fs from "fs"; +import dateFormat from "dateformat" +import cmd from "cmd-promise"; +import generator from "generate-password" +import jsonfile from "jsonfile" +import date from "date-and-time"; +import Dockerode from 'simple-dockerode'; +var docker = new Dockerode({ socketPath: '/var/run/docker.sock' }); +let finished +let commandToRun +let ram +let vram +let cpus +let ifApt +let end = "<=================================END===========================>" + /*################################## TWITTER API #########################################*/ const config = { @@ -98,7 +112,7 @@ async function getMentionedTweet() { /* IF BOT IS MENTIONED **IN** THE TWEET */ if (response.includes.tweets === undefined) { //check if the tweet is a reply to another tweet - const tweet = JSON.stringify(response.data.text, null, 2).replace(/(https?:\/\/[^\s]+)/g, '').replace(/"/g, '').trim();r + const tweet = JSON.stringify(response.data.text, null, 2).replace(/(https?:\/\/[^\s]+)/g, '').replace(/"/g, '').trim(); r console.log(response.data) const reply = "works" @@ -106,13 +120,401 @@ async function getMentionedTweet() { } else { /* IF BOT IS MENTIONED **UNDER** THE TWEET THEN IT WILL REPLY TO WHOEVER MENTIONED THE BOT BUT WILL TAKE QUESTIONS FROM THE ORIGINAL AUTHORS TWEET */ - let userID = response.data.author_id + let userID = response.data.author_id + + console.log("User ID: " + userID) + + + /////////////////////////////GENERATE + if (response.data.text.includes(`generate`)) { + cmd(`node /home/opc/genmulti_twit.js` + " " + userID + " " + userID + " " + userID + " ubuntu " + userID).then(out => { + console.log('out =', out) + const tweet = JSON.stringify(response.includes.tweets[0].text, null, 2).replace(/(https?:\/\/[^\s]+)/g, '').replace(/"/g, '').trim(); //remove the urls and double quotes from the tweet and trim the spaces + + const now = new Date(); + + var password = generator.generate({ + length: 10, + numbers: true + }); + + let rootPass = password + + cmd("node /exec/dockerexec.js " + userID + " " + "/home" + " " + "\"" + "echo \'root:" + rootPass + "\' | chpasswd" + "\"").then(out => { + (async () => { + + console.log('out =', out.stdout) + + const reply = "Generated!" //get the joke from the openai api + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + })(); + + }).catch(err => { + console.log('err=', err) + if (err.toString().includes("Conflict")) { + return + } + }).catch(err => { + console.log('err =', err) + }) + }).catch(err => { + (async () => { + console.log(err) + (async () => { + const reply = "You have a container!" //get the joke from the openai api + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + })(); console.log(end) + })(); + console.log(err) + return + }) + + } + + + ////////////////////////////////////// + + + + // if (response.data.text.includes(`exec`)) { + const tweet = JSON.stringify(response.includes.tweets[0].text, null, 2).replace("exec ", "").replace("@twit-linux ", ""); //remove the urls and double quotes from the tweet and trim the spaces + + console.log("RUN") + await cmd('bash /home/opc/check_exist.sh ' + userID).then(out => { + console.log('out =', out) + if (out.stdout != 1) { + (async () => { + finished = 1 + console.log(end) + const reply = "You do not have a container! Use the generate command to make one." //get the joke from the openai api + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + })(); + + } + + }).catch(err => { + console.log('err =', err) + }) + console.log("Begin Done") + + if (finished == 1) { + finished = 0 + return + } else { + + const path = 'cache/' + userID + + let code = tweet.replace("@twit_liux ", "").replace("exec ", "").replace(/['"]+/g, '') + if (code.startsWith("apt install") || code.startsWith("yum install")) { + if (!code.includes("-y")) { + code = code + " -y" + console.log(code) + } + } + + if (code.startsWith("pacman install")) { + if (!code.includes("--noconfirm")) { + code = code + " --noconfirm" + console.log(code) + } + } + + + if (code.startsWith("neofetch")) { + code = "neofetch --stdout" + } + + if (fs.existsSync(path)) { + console.log("") + } + else { + console.log("No Channel PWD Found! Generating!") + fs.writeFile('./cache/' + userID, "{\"pwd\":\"/\"}", function (err) { + }); + } + commandToRun = code.replace("@twit_linux ", "").replace("exec ", "").replace(/['"]+/g, '') + console.log("Running: " + commandToRun) + if (commandToRun == "yes") return console.log("yes Blocked") + + /** + * + * Start of Print Working Directory + * + */ + if (commandToRun == "pwd") { + goNoFurther = true + // check for channel pwd support file + if (fs.existsSync(path)) { + console.log("Channel PWD is active") + jsonfile = require('jsonfile') + jsonfile.readFile(path, function (err, pwdata) { + // console.log(pwdata) + (async () => { + + + const reply = pwdata.pwd //get the joke from the openai api + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + })(); + goNoFurther = false; + if (err) console.error(err) + }) + } + function escapeDoubleQuotes(str) { + return str.replace(/\\([\s\S])|(")/g, "\\$1$2"); // thanks @slevithan! + } + } + /** + * + * Main + * + */ + if (commandToRun == "pwd") return + + + /** + * + * Start of CD + * + */ + if (commandToRun.startsWith("cd")) { + console.log("test") + argscmd = tweet + + + // check for channel pwd support file + + if (fs.existsSync(path)) { + console.log("Channel PWD is active") + jsonfile = require('jsonfile') + jsonfile.readFile(path, function (err, pwdata) { + let argscmd = commandToRun.replace("cd ", "") + let dir = argscmd; // yes, start at 0, not 1. I hate that too. + + + if (startsWith(argscmd, "/") == false) { + const cmd = require('cmd-promise') + if (!argscmd) { + (async () => { + + const reply = "Give my Syntax Please" //get the joke from the openai api + await replyToTweet(reply, response.data.author_id, response.data.id); + })(); + return + } + + let dir = commandToRun; // yes, start at 0, not 1. I hate that too. + let data + jsonfile.readFile(path, function (err, pwdata) { + if (err) console.error(err) + console.log(dir) + data = pwdata.pwd + "/" + argscmd + if (pwdata.pwd == "/") { + data = "/" + argscmd + } + if (argscmd == "~") { + data = "/root" + } + if (argscmd.includes("~") && argscmd.includes("/")) { + data = "/root" + "/" + argscmd.replace("~", "") + } + + if (argscmd.includes("..") || argscmd.includes("../")) { // check if the user is trying to go back a directory + + console.log(argscmd.split("../")) + console.log("user wants to go back " + argscmd.split("../").length + " directories") + + function RemoveLastDirectoryPartOf(the_url, num) { + var the_arr = the_url.split('/'); + the_arr.splice(-num, num) + return (the_arr.join('/')); + } + data = RemoveLastDirectoryPartOf(pwdata.pwd, argscmd.split("../").length - 1) + } + + let final = data.replace(/([^:]\/)\/+/g, "$1") + console.log(final) + + const obj = { + pwd: final + } + jsonfile.writeFile(path, obj, function (err) { + (async () => { + + const reply = "Directory Changed to: " + final + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + })(); + if (err) console.error(err) + }) + + }); + + } else { + jsonfile.readFile(path, function (err, pwdata) { + if (err) console.error(err) + console.log('dir:' + dir) + //onsole.log(dir) + + const obj = { + pwd: dir.replace(/([^:]\/)\/+/g, "$1") + } + jsonfile.writeFile(path, obj, function (err) { + if (err) console.error(err) + }) + goNoFurther = false; + }); + (async () => { + const reply = "Directory Changed to: " + dir.replace(/([^:]\/)\/+/g, "$1") + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + })(); + } + function RemoveLastDirectoryPartOf(the_url) { + var the_arr = the_url.split('/'); + the_arr.pop(); + return (the_arr.join('/')); + } + function startsWith(str, word) { + return str.lastIndexOf(word, 0) === 0; + } + }) + } + } + /** + * + * End of CD + * + */ + if (commandToRun.startsWith("cd")) return console.log("Skipped At Main") + if (commandToRun.startsWith("write")) return + if (commandToRun == "gobk") return + + if (fs.existsSync(path)) { + function RemoveLastDirectoryPartOf(the_url) { + var the_arr = the_url.split('/'); + the_arr.pop(); + return (the_arr.join('/')); + } + console.log("Channel PWD is active") + jsonfile.readFile(path, function (err, pwdata) { + console.log(pwdata) + if (code == "neofetch") { + code = "neofetch --stdout --color_blocks off" + } + if (code.startsWith("apt")) { + ifApt = "-y" + } else if (code.startsWith("yum")) { + ifApt = "-y" + } + else if (code.startsWith("pacman")) { + ifApt = "--noconfirm" + } else if (code.startsWith("apt-get")) { + ifApt = "-y" + } + else { + ifApt = "" + } + + if (code.includes("~")) { + code = code.replace("~", "/root") + } + if (code.includes("..")) { + pwdata.pwd = RemoveLastDirectoryPartOf(pwdata.pwd) + } + + + // if (code.includes("../")) { // check if the user is trying to go back a directory + + // function RemoveLastDirectoryPartOf(the_url, num) { + // var the_arr = the_url.split('/'); + // the_arr.splice(-num, num) + // return (the_arr.join('/')); + // } + // console.log(argscmd.split("../")) + // console.log("user wants to go back " + argscmd.split("../").length -1 + " directories in their command") + + // pwddata.pwd = RemoveLastDirectoryPartOf(pwdata.pwd, argscmd.split("../").length - 1) + // } + + + const customerContainer = docker.getContainer(userID); + // Simple to grab the stdout and stderr. + customerContainer.exec(['/bin/bash', '-c', 'cd ' + pwdata.pwd + ' && ' + commandToRun], { stdout: true, stderr: true }, (err, out) => { + if (typeof (out) !== 'undefined') { + console.log(out.stdout) + + if (out.inspect.ExitCode !== 0) { + if (out.stderr.includes("syntax error")) { + (async () => { + const reply = "There is an error in your syntax, please try again." + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + console.log(end) + + })(); + } else { + (async () => { + const reply = out.stderr + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + + console.log(end) + + })(); + } + } + if (out.inspect.ExitCode == 0) { + if (!out.stdout) { + (async () => { + const reply = 'Command Executed Successfully!' + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + + })(); + } else { + if (out.stdout.length > 230) { + fs.writeFile('/tmp/paste', "Command: " + code.replace("--stdout --color_blocks off", "") + " | Container Owner: " + userID + "\n" + out.stdout, err => { + if (err) { + console.error(err) + return + } + }) + cmd("sleep 2; cat /tmp/paste | dpaste").then(pasteout => { + + (async () => { + console.log(end) + const reply = "Too Large, Check: " + pasteout.stdout.replace("paste.discord-linux.com", "twit-log.ssh.surf").replace("Pro tip: you can password protect your paste just by typing a username and password after your paste command.", "").replace("Paste Saved: ", "").replace("-------------------------------------------------------", "") //get the joke from the openai api + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + + })(); + + }) + } + else { + + + //<@UserID NUMBER> + (async () => { + const reply = out.stdout //get the joke from the openai api + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + console.log("<=================================END===========================>") + })(); + } + } + } + } else { + (async () => { + const reply = "Your container either needs to be generated or is not running." //get the joke from the openai api + await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the + return console.log(end) + })(); + } + }) + }) + } + } + + + + + - console.log("User ID: ") - const tweet = JSON.stringify(response.includes.tweets[0].text, null, 2).replace(/(https?:\/\/[^\s]+)/g, '').replace(/"/g, '').trim(); //remove the urls and double quotes from the tweet and trim the spaces - const reply = "Not Programmed Yet!" //get the joke from the openai api - await replyToTweet(reply, response.data.author_id, response.data.id); // reply to the } } } diff --git a/orders_generated.log b/orders_generated.log new file mode 100644 index 0000000..c63b7af --- /dev/null +++ b/orders_generated.log @@ -0,0 +1,27 @@ +2022.12.07, 17:50:39.0693 UTC -> ------New Order Recived-------- +2022.12.07, 17:50:39.0698 UTC -> 17205852,17205852,17205852,ubuntu,17205852 +2022.12.07, 17:50:39.0698 UTC -> Starting network scan...selecting 6. +2022.12.07, 17:50:39.0698 UTC -> Attempting to Generate the User +2022.12.07, 17:50:40.0925 UTC -> Ports selected: 14611-14615 +2022.12.07, 17:50:40.0926 UTC -> Adding user to the customer team for access... +2022.12.07, 17:50:41.0362 UTC -> Adding user to the resource control to lock out other customers +2022.12.07, 17:50:41.0382 UTC -> User Successfully Added to ACL, Container is ready for use! +2022.12.07, 17:50:41.0383 UTC -> ------Order Process Completed-------- +2022.12.07, 17:53:48.0262 UTC -> ------New Order Recived-------- +2022.12.07, 17:53:48.0267 UTC -> 17205852,17205852,17205852,ubuntu,17205852 +2022.12.07, 17:53:48.0267 UTC -> Attempting to Generate the User +2022.12.07, 17:53:48.0268 UTC -> Starting network scan...selecting 6. +2022.12.07, 17:53:49.0350 UTC -> Ports selected: 24627-24631 +2022.12.07, 17:53:49.0350 UTC -> Adding user to the customer team for access... +2022.12.07, 17:53:49.0678 UTC -> Adding user to the resource control to lock out other customers +2022.12.07, 17:53:49.0704 UTC -> User Successfully Added to ACL, Container is ready for use! +2022.12.07, 17:53:49.0704 UTC -> ------Order Process Completed-------- +2022.12.07, 17:55:55.0317 UTC -> ------New Order Recived-------- +2022.12.07, 17:55:55.0322 UTC -> 1600528742396399616,1600528742396399616,1600528742396399616,ubuntu,1600528742396399616 +2022.12.07, 17:55:55.0322 UTC -> Starting network scan...selecting 6. +2022.12.07, 17:55:55.0322 UTC -> Attempting to Generate the User +2022.12.07, 17:55:56.0369 UTC -> Ports selected: 23857-23861 +2022.12.07, 17:55:56.0370 UTC -> Adding user to the customer team for access... +2022.12.07, 17:55:56.0772 UTC -> Adding user to the resource control to lock out other customers +2022.12.07, 17:55:56.0791 UTC -> User Successfully Added to ACL, Container is ready for use! +2022.12.07, 17:55:56.0791 UTC -> ------Order Process Completed-------- diff --git a/package-lock.json b/package-lock.json index 875f92d..a481af0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,13 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "cmd-promise": "^1.2.0", + "date-and-time": "^2.4.1", + "dateformat": "^5.0.3", "dotenv": "^16.0.2", + "generate-password": "^1.7.0", "openai": "^3.0.0", + "simple-dockerode": "^0.2.2", "twit": "^2.2.11", "twitter-api-sdk": "^1.1.0" } @@ -91,16 +96,59 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/bl": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", + "dependencies": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, + "node_modules/buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "dependencies": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "node_modules/buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "node_modules/buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==" + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "node_modules/cmd-promise": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/cmd-promise/-/cmd-promise-1.2.0.tgz", + "integrity": "sha512-6lxSMygXwx7PPoOsK4k41DFHXeF/bsu4q4MyPL9MQkRHFzxiLqkgWl0FfoJV0w3VOo8AvCDzPLnCMgp4DB0SfQ==" + }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -112,6 +160,20 @@ "node": ">= 0.8" } }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -128,6 +190,27 @@ "node": ">=0.10" } }, + "node_modules/date-and-time": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-2.4.1.tgz", + "integrity": "sha512-fG+ClATev+wHryqxOoGcTTegr5RhYE+tz/XHUkTQ/zvpWqQ90oOxjOhuMQ02bw87Oy9N3qBENCHHHSKdWJjgTg==" + }, + "node_modules/dateformat": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-5.0.3.tgz", + "integrity": "sha512-Kvr6HmPXUMerlLcLF+Pwq3K7apHpYmGDVqrxcDasBg86UcKeTSNWbEzU8bwdXnxnR44FtMhJAxI4Bov6Y/KUfA==", + "engines": { + "node": ">=12.20" + } + }, + "node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dependencies": { + "ms": "^2.1.1" + } + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -136,6 +219,54 @@ "node": ">=0.4.0" } }, + "node_modules/docker-modem": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/docker-modem/-/docker-modem-1.0.9.tgz", + "integrity": "sha512-lVjqCSCIAUDZPAZIeyM125HXfNvOmYYInciphNrLrylUtKyW66meAjSPXWchKVzoIYZx69TPnAepVSSkeawoIw==", + "dependencies": { + "debug": "^3.2.6", + "JSONStream": "1.3.2", + "readable-stream": "~1.0.26-4", + "split-ca": "^1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/docker-modem/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" + }, + "node_modules/docker-modem/node_modules/readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/docker-modem/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==" + }, + "node_modules/dockerode": { + "version": "2.5.8", + "resolved": "https://registry.npmjs.org/dockerode/-/dockerode-2.5.8.tgz", + "integrity": "sha512-+7iOUYBeDTScmOmQqpUYQaE7F4vvIt6+gIZNHWhqAQEI887tiPFB9OvXI/HzQYqfUNvukMK+9myLW63oTJPZpw==", + "dependencies": { + "concat-stream": "~1.6.2", + "docker-modem": "^1.0.8", + "tar-fs": "~1.16.3" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/dotenv": { "version": "16.0.2", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.2.tgz", @@ -153,6 +284,14 @@ "safer-buffer": "^2.1.0" } }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -224,6 +363,16 @@ "node": ">= 6" } }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "node_modules/generate-password": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/generate-password/-/generate-password-1.7.0.tgz", + "integrity": "sha512-WPCtlfy0jexf7W5IbwxGUgpIDvsZIohbI2DAq2Q6TSlKKis+G4GT9sxvPxrZUGL8kP6WUXMWNqYnxY6DDKAdFA==" + }, "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -267,11 +416,21 @@ "npm": ">=1.3.7" } }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -297,6 +456,29 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" }, + "node_modules/jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", + "engines": [ + "node >= 0.2.0" + ] + }, + "node_modules/JSONStream": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", + "integrity": "sha512-mn0KSip7N4e0UDPZHnqDsHECo5uGQrixQKnAskOM1BIB8hd7QKbd6il8IPRPudPHOeHiECoCFqhyMaRO9+nWyA==", + "dependencies": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + }, + "bin": { + "JSONStream": "bin.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -341,6 +523,30 @@ "node": ">= 0.6" } }, + "node_modules/minimist": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, "node_modules/node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -368,6 +574,14 @@ "node": "*" } }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/openai": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/openai/-/openai-3.0.0.tgz", @@ -382,11 +596,25 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" }, + "node_modules/pump": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "node_modules/punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -403,6 +631,25 @@ "node": ">=0.6" } }, + "node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, "node_modules/request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -471,6 +718,21 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/simple-dockerode": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-dockerode/-/simple-dockerode-0.2.2.tgz", + "integrity": "sha512-n+7ccTniRAR28RDVofqFYEdBs2TvJG+nYKQn0v2wlThjrKDj/HG8VIFZt+D1BeeGnqIdkjvB60EGXoFFjbmiJA==", + "dependencies": { + "dockerode": "^2.5.3", + "isstream": "^0.1.2", + "streambattery": "^0.1.0" + } + }, + "node_modules/split-ca": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split-ca/-/split-ca-1.0.1.tgz", + "integrity": "sha512-Q5thBSxp5t8WPTTJQS59LrGqOZqOsrhDGDVm8azCqIBjSBd7nd9o2PM+mDulQQkh8h//4U6hFZnc/mul8t5pWQ==" + }, "node_modules/sshpk": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", @@ -495,6 +757,62 @@ "node": ">=0.10.0" } }, + "node_modules/streambattery": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/streambattery/-/streambattery-0.1.0.tgz", + "integrity": "sha512-KroIY5WtU4cKFx06FZfK0bn+/tc8jgPfuOM+ilIVvJy/elyK0oDyx0VKCEtxnn3oEXaLN2OZCLG/La5vaHwLZA==" + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/tar-fs": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz", + "integrity": "sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==", + "dependencies": { + "chownr": "^1.0.1", + "mkdirp": "^0.5.1", + "pump": "^1.0.0", + "tar-stream": "^1.1.2" + } + }, + "node_modules/tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "dependencies": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" + }, + "node_modules/to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" + }, "node_modules/tough-cookie": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", @@ -553,6 +871,11 @@ "node": ">=14" } }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -561,6 +884,11 @@ "punycode": "^2.1.0" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, "node_modules/uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", @@ -596,6 +924,19 @@ "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } } }, "dependencies": { @@ -662,16 +1003,59 @@ "tweetnacl": "^0.14.3" } }, + "bl": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", + "requires": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, + "buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "requires": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==" + }, + "buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "cmd-promise": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/cmd-promise/-/cmd-promise-1.2.0.tgz", + "integrity": "sha512-6lxSMygXwx7PPoOsK4k41DFHXeF/bsu4q4MyPL9MQkRHFzxiLqkgWl0FfoJV0w3VOo8AvCDzPLnCMgp4DB0SfQ==" + }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -680,6 +1064,17 @@ "delayed-stream": "~1.0.0" } }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -693,11 +1088,73 @@ "assert-plus": "^1.0.0" } }, + "date-and-time": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-2.4.1.tgz", + "integrity": "sha512-fG+ClATev+wHryqxOoGcTTegr5RhYE+tz/XHUkTQ/zvpWqQ90oOxjOhuMQ02bw87Oy9N3qBENCHHHSKdWJjgTg==" + }, + "dateformat": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-5.0.3.tgz", + "integrity": "sha512-Kvr6HmPXUMerlLcLF+Pwq3K7apHpYmGDVqrxcDasBg86UcKeTSNWbEzU8bwdXnxnR44FtMhJAxI4Bov6Y/KUfA==" + }, + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "requires": { + "ms": "^2.1.1" + } + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" }, + "docker-modem": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/docker-modem/-/docker-modem-1.0.9.tgz", + "integrity": "sha512-lVjqCSCIAUDZPAZIeyM125HXfNvOmYYInciphNrLrylUtKyW66meAjSPXWchKVzoIYZx69TPnAepVSSkeawoIw==", + "requires": { + "debug": "^3.2.6", + "JSONStream": "1.3.2", + "readable-stream": "~1.0.26-4", + "split-ca": "^1.0.0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==" + } + } + }, + "dockerode": { + "version": "2.5.8", + "resolved": "https://registry.npmjs.org/dockerode/-/dockerode-2.5.8.tgz", + "integrity": "sha512-+7iOUYBeDTScmOmQqpUYQaE7F4vvIt6+gIZNHWhqAQEI887tiPFB9OvXI/HzQYqfUNvukMK+9myLW63oTJPZpw==", + "requires": { + "concat-stream": "~1.6.2", + "docker-modem": "^1.0.8", + "tar-fs": "~1.16.3" + } + }, "dotenv": { "version": "16.0.2", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.2.tgz", @@ -712,6 +1169,14 @@ "safer-buffer": "^2.1.0" } }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, "event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -757,6 +1222,16 @@ "mime-types": "^2.1.12" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "generate-password": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/generate-password/-/generate-password-1.7.0.tgz", + "integrity": "sha512-WPCtlfy0jexf7W5IbwxGUgpIDvsZIohbI2DAq2Q6TSlKKis+G4GT9sxvPxrZUGL8kP6WUXMWNqYnxY6DDKAdFA==" + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -789,11 +1264,21 @@ "sshpk": "^1.7.0" } }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -819,6 +1304,20 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" }, + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==" + }, + "JSONStream": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", + "integrity": "sha512-mn0KSip7N4e0UDPZHnqDsHECo5uGQrixQKnAskOM1BIB8hd7QKbd6il8IPRPudPHOeHiECoCFqhyMaRO9+nWyA==", + "requires": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + } + }, "jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -848,6 +1347,24 @@ "mime-db": "1.52.0" } }, + "minimist": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==" + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "requires": { + "minimist": "^1.2.6" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, "node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -861,6 +1378,14 @@ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "requires": { + "wrappy": "1" + } + }, "openai": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/openai/-/openai-3.0.0.tgz", @@ -875,11 +1400,25 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" }, + "pump": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -890,6 +1429,27 @@ "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==" }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, "request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -939,6 +1499,21 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "simple-dockerode": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-dockerode/-/simple-dockerode-0.2.2.tgz", + "integrity": "sha512-n+7ccTniRAR28RDVofqFYEdBs2TvJG+nYKQn0v2wlThjrKDj/HG8VIFZt+D1BeeGnqIdkjvB60EGXoFFjbmiJA==", + "requires": { + "dockerode": "^2.5.3", + "isstream": "^0.1.2", + "streambattery": "^0.1.0" + } + }, + "split-ca": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split-ca/-/split-ca-1.0.1.tgz", + "integrity": "sha512-Q5thBSxp5t8WPTTJQS59LrGqOZqOsrhDGDVm8azCqIBjSBd7nd9o2PM+mDulQQkh8h//4U6hFZnc/mul8t5pWQ==" + }, "sshpk": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", @@ -955,6 +1530,61 @@ "tweetnacl": "~0.14.0" } }, + "streambattery": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/streambattery/-/streambattery-0.1.0.tgz", + "integrity": "sha512-KroIY5WtU4cKFx06FZfK0bn+/tc8jgPfuOM+ilIVvJy/elyK0oDyx0VKCEtxnn3oEXaLN2OZCLG/La5vaHwLZA==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "tar-fs": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz", + "integrity": "sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==", + "requires": { + "chownr": "^1.0.1", + "mkdirp": "^0.5.1", + "pump": "^1.0.0", + "tar-stream": "^1.1.2" + } + }, + "tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "requires": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + } + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" + }, + "to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" + }, "tough-cookie": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", @@ -1001,6 +1631,11 @@ "node-fetch": "^2.6.1" } }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -1009,6 +1644,11 @@ "punycode": "^2.1.0" } }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", @@ -1037,6 +1677,16 @@ "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" } } } diff --git a/package.json b/package.json index a78711c..e84d7a3 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,14 @@ "author": "Rohit Kumar", "license": "ISC", "dependencies": { + "cmd-promise": "^1.2.0", + "date-and-time": "^2.4.1", + "dateformat": "^5.0.3", "dotenv": "^16.0.2", + "generate-password": "^1.7.0", "openai": "^3.0.0", + "simple-dockerode": "^0.2.2", "twit": "^2.2.11", "twitter-api-sdk": "^1.1.0" } -} \ No newline at end of file +} diff --git a/show.js b/show.js new file mode 100644 index 0000000..d83597c --- /dev/null +++ b/show.js @@ -0,0 +1,491 @@ +const { Embed } = require("discord.js"); +const fs = require("fs"); +const dateFormat = require("dateformat"); +require('dotenv').config() +const cmd = require('cmd-promise') +var portastic = require('portastic'); +const { stderr } = require("process"); +let jsonfile = require('jsonfile') +let rand = Math.floor(Math.random() * 99999999999999); +let code +let ifApt +const date = require('date-and-time'); +const now = new Date(); +const { EmbedBuilder } = require('discord.js'); +const Dockerode = require('simple-dockerode'); +var docker = new Dockerode({ socketPath: '/var/run/docker.sock' }); +let finished +let end = "<=================================END===========================>" + +module.exports = { + name: "x", + description: "Execute a command non-interactively.", + options: [{ + "name": "cmd", + "description": "Command to Execute", + "required": true, + "type": 3 // 6 is type USER + }], + + run: async (client, interaction) => { + console.log("RUN") + await cmd('bash /home/opc/check_exist.sh ' + interaction.user.id).then(out => { + console.log('out =', out) + if (out.stdout != 1) { + (async () => { + finished = 1 + console.log(end) + + return await interaction.editReply("Sorry, you do not have a container currently, generate one using /generate") + })(); + + } + + }).catch(err => { + console.log('err =', err) + }) + console.log("Begin Done") + + if (finished == 1) { + finished = 0 + return + } else { + + // await interaction.deferReply(); + const path = 'cache/' + interaction.user.id + const isNotDefined = require("is-not-defined"); + if (isNotDefined(interaction.options._hoistedOptions)) { + (async () => { + await interaction.editReply("You must supply a command.") + + })(); + return + } + let code = interaction.options._hoistedOptions[0].value + if (code.startsWith("apt install") || code.startsWith("yum install")) { + if (!code.includes("-y")) { + code = code + " -y" + console.log(code) + } + } + + if (code.startsWith("pacman install")) { + if (!code.includes("--noconfirm")) { + code = code + " --noconfirm" + console.log(code) + } + } + + + if (code.startsWith("neofetch")) { + code = "neofetch --stdout" + } + + if (fs.existsSync(path)) { + console.log("") + } + else { + console.log("No Channel PWD Found! Generating!") + fs.writeFile('./cache/' + interaction.user.id, "{\"pwd\":\"/\"}", function (err) { + }); + } + commandToRun = code + if (commandToRun == "yes") return console.log("yes Blocked") + + /** + * + * Start of Print Working Directory + * + */ + if (commandToRun == "pwd") { + goNoFurther = true + // check for channel pwd support file + if (fs.existsSync(path)) { + console.log("Channel PWD is active") + jsonfile = require('jsonfile') + jsonfile.readFile(path, function (err, pwdata) { + // console.log(pwdata) + (async () => { + await interaction.editReply("```" + pwdata.pwd + "```") + })(); + goNoFurther = false; + if (err) console.error(err) + }) + } + function escapeDoubleQuotes(str) { + return str.replace(/\\([\s\S])|(")/g, "\\$1$2"); // thanks @slevithan! + } + } + /** + * + * Main + * + */ + if (commandToRun == "pwd") return + // /** + // * + // * Start of Write + // * + // */ + // console.log("cmd: " + commandToRun) + // if (commandToRun.startsWith("write")) { + // const echoFile = require('write'); + // const cmd = require('cmd-promise') + // re = /\{([\s\S)]+)\}/; + // re2 = /\^(.*)\^/; + // if (commandToRun.toString().includes("\n")) console.log("YES! BREAK") + // let cdcmdtest = commandToRun // First index is removed and array is returned. + // jsonfile.readFile(path, function (err, pwdata) { + // if (err) console.error(err) + // // Regular Expression To find Sections fo command + // let codeToSend = cdcmdtest.match(re)[1]; // yes, start at 0, not 1. I hate that too. + // console.log("codeToSend: " + codeToSend) + // let fileToSend = cdcmdtest.match(re2)[1]; // yes, start at 0, not 1. I hate that too. + // console.log("file: " + fileToSend) + // // let usrcmd = cdcmdtest.slice(0).join(" "); + // jsonfile.readFile(path, function (err, pwdata) { + // if (err) console.error(err) + // //await interaction.editReply(pwdata.pwd); + // const cmd = require('cmd-promise') + // // let usrcmd = cdcmdtest.slice(0).join(" "); + // console.log("/tmp/tmpfile/" + rand + "/" + fileToSend) + // echoFile.sync("/tmp/tmpfile/" + rand + "/" + fileToSend, codeToSend, { + // newline: true + // }); + // console.log('docker cp ' + "/tmp/tmpfile/" + rand + "/" + fileToSend + ' ' + interaction.user.id + ':' + pwdata.pwd) + // cmd('docker cp ' + "/tmp/tmpfile/" + + rand + "/" + fileToSend + ' ' + interaction.user.id + ':' + pwdata.pwd).then(out => { + // console.log('out =', out) + // try { + // fs.unlinkSync("/tmp/tmpfile/" + + rand + "/" + fileToSend) + // console.log("tmpfileremoved") + // rand = Math.floor(Math.random() * 99999999999999); + // } catch (err) { + // console.error(err) + // } + // }).catch(err => { + // console.log('err =', err) + // }) + // (async () => { + // await interaction.editReply("File Saved as " + fileToSend); + // })(); + // }) + // }) + // } + /** + * + * Start of CDX + * + */ + // if (commandToRun == "gobk") { + // // check for channel pwd support file + + // if (fs.existsSync(path)) { + // console.log("Channel PWD is active") + // jsonfile.readFile(path, function (err, pwdata) { + // if (err) console.error(err) + // console.log(RemoveLastDirectoryPartOf(pwdata.pwd)) + // //console.log(dir) + // if (RemoveLastDirectoryPartOf(pwdata.pwd).length == 0) { + // obj = { + // pwd: "/" + // } + // } else { + // obj = { + // pwd: RemoveLastDirectoryPartOf(pwdata.pwd) + // } + // } + // jsonfile.writeFile(path, obj, function (err) { + // (async () => { + // await interaction.editReply(obj.pwd); + // })(); + // if (err) console.error(err) + // }) + // }); + // function RemoveLastDirectoryPartOf(the_url) { + // var the_arr = the_url.split('/'); + // the_arr.pop(); + // return (the_arr.join('/')); + // } + // function startsWith(str, word) { + // return str.lastIndexOf(word, 0) === 0; + // } + // } + // } + /** + * + * End of CDX + * + */ + /** + * + * Start of CD + * + */ + if (commandToRun.startsWith("cd")) { + console.log("test") + argscmd = interaction.options._hoistedOptions[0].value + if (argscmd == "..") { + (async () => { + await interaction.editReply("please use the gobk command to go back a directory") + })(); + return + } + + // check for channel pwd support file + + if (fs.existsSync(path)) { + console.log("Channel PWD is active") + jsonfile = require('jsonfile') + jsonfile.readFile(path, function (err, pwdata) { + let argscmd = commandToRun.replace("cd ", "") + let dir = argscmd; // yes, start at 0, not 1. I hate that too. + + + if (startsWith(argscmd, "/") == false) { + const cmd = require('cmd-promise') + if (!argscmd) { + (async () => { + await interaction.editReply("Give my Syntax Please") + })(); + return + } + + let dir = commandToRun; // yes, start at 0, not 1. I hate that too. + let data + jsonfile.readFile(path, function (err, pwdata) { + if (err) console.error(err) + console.log(dir) + data = pwdata.pwd + "/" + argscmd + if (pwdata.pwd == "/") { + data = "/" + argscmd + } + if (argscmd == "~") { + data = "/root" + } + if (argscmd.includes("~") && argscmd.includes("/")) { + data = "/root" + "/" + argscmd.replace("~", "") + } + + if (argscmd.includes("..") || argscmd.includes("../")) { // check if the user is trying to go back a directory + + console.log(argscmd.split("../")) + console.log("user wants to go back " + argscmd.split("../").length + " directories") + + function RemoveLastDirectoryPartOf(the_url, num) { + var the_arr = the_url.split('/'); + the_arr.splice(-num, num) + return (the_arr.join('/')); + } + data = RemoveLastDirectoryPartOf(pwdata.pwd, argscmd.split("../").length - 1) + } + + let final = data.replace(/([^:]\/)\/+/g, "$1") + console.log(final) + + const obj = { + pwd: final + } + jsonfile.writeFile(path, obj, function (err) { + (async () => { + await interaction.editReply("Directory Changed to: " + final) + })(); + if (err) console.error(err) + }) + + }); + + } else { + jsonfile.readFile(path, function (err, pwdata) { + if (err) console.error(err) + console.log('dir:' + dir) + //onsole.log(dir) + + const obj = { + pwd: dir.replace(/([^:]\/)\/+/g, "$1") + } + jsonfile.writeFile(path, obj, function (err) { + if (err) console.error(err) + }) + goNoFurther = false; + }); + (async () => { + await interaction.editReply("Directory Changed to: " + dir.replace(/([^:]\/)\/+/g, "$1")) + })(); + } + function RemoveLastDirectoryPartOf(the_url) { + var the_arr = the_url.split('/'); + the_arr.pop(); + return (the_arr.join('/')); + } + function startsWith(str, word) { + return str.lastIndexOf(word, 0) === 0; + } + }) + } + } + /** + * + * End of CD + * + */ + if (commandToRun.startsWith("cd")) return console.log("Skipped At Main") + if (commandToRun.startsWith("write")) return + if (commandToRun == "gobk") return + + if (fs.existsSync(path)) { + function RemoveLastDirectoryPartOf(the_url) { + var the_arr = the_url.split('/'); + the_arr.pop(); + return (the_arr.join('/')); + } + console.log("Channel PWD is active") + jsonfile.readFile(path, function (err, pwdata) { + console.log(pwdata) + if (code == "neofetch") { + code = "neofetch --stdout --color_blocks off" + } + if (code.startsWith("apt")) { + ifApt = "-y" + } else if (code.startsWith("yum")) { + ifApt = "-y" + } + else if (code.startsWith("pacman")) { + ifApt = "--noconfirm" + } else if (code.startsWith("apt-get")) { + ifApt = "-y" + } + else { + ifApt = "" + } + + if (code.includes("~")) { + code = code.replace("~", "/root") + } + if (code.includes("..")) { + pwdata.pwd = RemoveLastDirectoryPartOf(pwdata.pwd) + } + + + // if (code.includes("../")) { // check if the user is trying to go back a directory + + // function RemoveLastDirectoryPartOf(the_url, num) { + // var the_arr = the_url.split('/'); + // the_arr.splice(-num, num) + // return (the_arr.join('/')); + // } + // console.log(argscmd.split("../")) + // console.log("user wants to go back " + argscmd.split("../").length -1 + " directories in their command") + + // pwddata.pwd = RemoveLastDirectoryPartOf(pwdata.pwd, argscmd.split("../").length - 1) + // } + + + const customerContainer = docker.getContainer(interaction.user.id); + // Simple to grab the stdout and stderr. + customerContainer.exec(['/bin/bash', '-c', 'cd ' + pwdata.pwd + ' && ' + commandToRun], { stdout: true, stderr: true }, (err, out) => { + if (typeof (out) !== 'undefined') { + console.log(out.stdout) + + if (out.inspect.ExitCode !== 0) { + if (out.stderr.includes("syntax error")) { + (async () => { + await interaction.editReply("```️️️️" + "There is an error in your syntax, please try again." + "```") + console.log(end) + + })(); + } else { + (async () => { + return await interaction.editReply("```️️️️" + out.stderr + "```") + console.log(end) + + })(); + } + } + if (out.inspect.ExitCode == 0) { + if (!out.stdout) { + + const mainEmbed = new EmbedBuilder() + .setColor('#0099ff') + .setTitle('Command Executed Successfully!') + .setDescription('```' + commandToRun + ' has completed.```') + .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); + (async () => { + return await interaction.editReply({ embeds: [mainEmbed] }) + console.log(end) + + })(); + } else { + if (out.stdout.length > 2020) { + fs.writeFile('/tmp/paste', "Command: " + code.replace("--stdout --color_blocks off", "") + " | Container Owner: " + interaction.user.username + "\n" + out.stdout, err => { + if (err) { + console.error(err) + return + } + }) + cmd("sleep 2; cat /tmp/paste | dpaste").then(pasteout => { + const mainEmbed = new EmbedBuilder() + .setColor('#0099ff') + .addFields( + { name: 'Please check the below output log:', value: pasteout.stdout.replace("Pro tip: you can password protect your paste just by typing a username and password after your paste command.", "").replace("Paste Saved: ", "").replace("-------------------------------------------------------", "") }, + ).setTitle("Container Owner: " + interaction.user.username) + .setDescription("The command: " + code.replace("--stdout --color_blocks off", "") + " was too large for discord.") + .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); + (async () => { + console.log(end) + return await interaction.editReply({ embeds: [mainEmbed] }) + + })(); + + }) + } + else { + // console.log("ahah " + code) + if (code.includes("dpaste")) { + + const mainEmbed = new EmbedBuilder() + .setColor('#0099ff') + .addFields( + { name: 'View your Paste at the link below!', value: out.stdout.replace("Pro tip: you can password protect your paste just by typing a username and password after your paste command.", "").replace("Paste Saved: ", "").replace("-------------------------------------------------------", "") }, + { name: 'Pro Tip!', value: "You can protect your paste by typing a username and password after dpaste." }, + ).setTitle("Paste Saved!") + .setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` }); + (async () => { + return await interaction.editReply({ embeds: [mainEmbed] }) + console.log(end) + + })(); + return + } + if (commandToRun.startsWith("cowsay") || commandToRun.startsWith("figlet")) { + (async () => { + await interaction.editReply("```️️️️" + out.stdout + "```") + })(); + return + } + + if (code.includes("figlet") || code.includes("figlet")) { + (async () => { + return await interaction.editReply("```️️️️" + out.stdout + "```") + console.log(end) + })(); + } + //<@UserID NUMBER> + (async () => { + await interaction.editReply("```️️️️" + "Command: " + code.replace("--stdout --color_blocks off", "") + " | Container Owner: " + interaction.user.username + "\n" + out.stdout + "```") + console.log("<=================================END===========================>") + })(); + } + } + } + } else { + (async () => { + await interaction.editReply("```️️️️" + "Your container either needs to be generated or is not running." + "```") + return console.log(end) + })(); + } + }) + }) + } + } + }, +}; \ No newline at end of file