summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-06-01 14:55:33 +0200
committerRaindropsSys <contact@minteck.org>2023-06-01 14:55:33 +0200
commitbc85347d36461704e5c39d5d3b07ca715d21704d (patch)
tree9c3330e70c94900485feb84befc26dffe397d092
parent6fbd992c91f93b7ba91f30c2ce6bf15a344d8495 (diff)
downloadbutterscotch-bc85347d36461704e5c39d5d3b07ca715d21704d.tar.gz
butterscotch-bc85347d36461704e5c39d5d3b07ca715d21704d.tar.bz2
butterscotch-bc85347d36461704e5c39d5d3b07ca715d21704d.zip
Updated 3 files and added 4 files (automated)
-rw-r--r--commands/eval.js20
-rw-r--r--commands/help.js2
-rw-r--r--commands/killswitch.js11
-rw-r--r--commands/what.js4
-rw-r--r--help/eval.json6
-rw-r--r--help/killswitch.json6
-rw-r--r--index.js31
7 files changed, 77 insertions, 3 deletions
diff --git a/commands/eval.js b/commands/eval.js
new file mode 100644
index 0000000..2d44252
--- /dev/null
+++ b/commands/eval.js
@@ -0,0 +1,20 @@
+module.exports = (parameter, wrapper) => {
+ if (wrapper.sender !== "@raindrops:equestria.dev" && wrapper.sender !== "493845599469174794") {
+ wrapper.send("⛔️ This command is private and you are not allowed to use it.");
+ return;
+ }
+
+ let start = new Date();
+
+ try {
+ let ret = eval(parameter);
+
+ try {
+ wrapper.send("✅ Completed in " + (new Date().getTime() - start) + " ms\n\n```plaintext\n" + JSON.stringify(ret, null, 2) + "\n```");
+ } catch (e) {
+ wrapper.send("⚠️ Completed with invalid JSON in " + (new Date().getTime() - start) + " ms\n\n```plaintext\n" + ret + "\n```");
+ }
+ } catch (e) {
+ wrapper.send("🚨 Failed after " + (new Date().getTime() - start) + " ms\n\n```plaintext\n" + e.stack + "\n```");
+ }
+} \ No newline at end of file
diff --git a/commands/help.js b/commands/help.js
index bf2971c..778a789 100644
--- a/commands/help.js
+++ b/commands/help.js
@@ -43,6 +43,6 @@ module.exports = (parameter, wrapper) => {
wrapper.send("😢 Sorry, no help is available for this command, try again later.");
}
} else {
- wrapper.send("👋 Hey! Here are all the commands you can use: " + fs.readdirSync("./commands").map((i) => "`." + i.substring(0, i.length - 3) + "`").join(", ") + "\n\nUse `.help [command]` to get help for a specific command.");
+ wrapper.send("👋 Hey! Here are all the commands you can use: " + fs.readdirSync("./commands").map((i) => "`." + i.substring(0, i.length - 3) + "`").join(", ") + "\n\nUse `.help [command]` to get help for a specific command. Version " + process.versions.butterscotch.substring(0, 10) + ".");
}
} \ No newline at end of file
diff --git a/commands/killswitch.js b/commands/killswitch.js
new file mode 100644
index 0000000..6a4751c
--- /dev/null
+++ b/commands/killswitch.js
@@ -0,0 +1,11 @@
+module.exports = (parameter, wrapper) => {
+ if (wrapper.sender !== "@raindrops:equestria.dev" && wrapper.sender !== "493845599469174794") {
+ wrapper.send("⛔️ This command is private and you are not allowed to use it.");
+ return;
+ }
+
+ wrapper.send("[💣](https://admin.equestria.dev/#v1:0:=lxc%2F211:4::::::=consolejs:)");
+ setTimeout(() => {
+ process.exit(2);
+ }, 1000);
+} \ No newline at end of file
diff --git a/commands/what.js b/commands/what.js
index 3c928fa..67c602a 100644
--- a/commands/what.js
+++ b/commands/what.js
@@ -1,6 +1,6 @@
module.exports = (parameter, wrapper) => {
- if (lastMessages[wrapper.room]) {
- wrapper.send("👓 Here are the last messages sent in this room:\n\n" + lastMessages[wrapper.room].map(i => "* " + i).join("\n"));
+ if (lastMessages[wrapper.id]) {
+ wrapper.send("👓 Here are the last messages sent in this room:\n\n" + lastMessages[wrapper.id].map(i => "* " + i).join("\n"));
} else {
wrapper.send("😢 Sorry, I haven't seen any message in this room yet.");
}
diff --git a/help/eval.json b/help/eval.json
new file mode 100644
index 0000000..08053cb
--- /dev/null
+++ b/help/eval.json
@@ -0,0 +1,6 @@
+{
+ "description": "Runs JavaScript code on the bot.",
+ "parameters": "<code>",
+ "aliases": [ "exec", "run", "code" ],
+ "exempt": false
+} \ No newline at end of file
diff --git a/help/killswitch.json b/help/killswitch.json
new file mode 100644
index 0000000..56eb9e8
--- /dev/null
+++ b/help/killswitch.json
@@ -0,0 +1,6 @@
+{
+ "description": "Forcefully stops the bot in case of an emergency.",
+ "parameters": "",
+ "aliases": [ "kill", "ks", "ass", "stop", "estop", "es" ],
+ "exempt": false
+} \ No newline at end of file
diff --git a/index.js b/index.js
index d6c63d5..5eb60aa 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,35 @@
const fs = require("fs");
+const path = require('path');
+
+const getAllFiles = function(dirPath, arrayOfFiles) {
+ let files = fs.readdirSync(dirPath);
+
+ arrayOfFiles = arrayOfFiles || [];
+
+ files.forEach(function(file) {
+ if (file === "cache") return;
+
+ if (fs.statSync(dirPath + "/" + file).isDirectory()) {
+ arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles);
+ } else {
+ arrayOfFiles.push(path.join(__dirname, dirPath, "/", file));
+ }
+ });
+
+ return arrayOfFiles
+}
+
+let files = getAllFiles(".");
+let sums = [];
+
+console.log("Computing version number...");
+
+for (let file of files) {
+ sums.push(require('crypto').createHash("md5").update(fs.readFileSync(file)).digest("hex"));
+}
+
+let sum = require('crypto').createHash("sha256").update(JSON.stringify(sums)).digest("hex");
+process.versions.butterscotch = sum;
if (!fs.existsSync("cache")) fs.mkdirSync("cache");
if (!fs.existsSync("cache/lastMessages.json")) fs.writeFileSync("cache/lastMessages.json", "{}");