Content Title
-
+
Content Text
From b0d36204ffded4f85a58316a6a809e8de0b3475d Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 16:30:33 -0700
Subject: [PATCH 21/27] **Changelog**
* Created a mod version of get_list_length_MOD.js this one only returns a number for the list length and not a list like 1,2,3. this also makes it so if the list is empty or is not a list it will be undefined
---
actions/get_list_length_MOD.js | 62 ++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 actions/get_list_length_MOD.js
diff --git a/actions/get_list_length_MOD.js b/actions/get_list_length_MOD.js
new file mode 100644
index 00000000..6df8f81e
--- /dev/null
+++ b/actions/get_list_length_MOD.js
@@ -0,0 +1,62 @@
+module.exports = {
+ name: "Get List Length",
+ section: "Lists and Loops",
+
+ subtitle(data, presets) {
+ const list = presets.lists;
+ return `Get ${list[parseInt(data.list, 10)]} Length`;
+ },
+
+ variableStorage(data, varType) {
+ const type = parseInt(data.storage, 10);
+ if (type !== varType) return;
+ return [data.varName2, "Number"];
+ },
+
+ meta: { version: "2.1.7", preciseCheck: true, author: null, authorUrl: null, downloadUrl: null },
+
+ fields: ["list", "varName", "storage", "varName2"],
+
+ html(isEvent, data) {
+ return `
+
+
+ Source List:
+
+ ${data.lists[isEvent ? 1 : 0]}
+
+
+
+ Variable Name:
+
+
+
+
+
+
+
`;
+ },
+
+ init() {
+ const { glob, document } = this;
+ glob.listChange(document.getElementById("list"), "varNameContainer");
+ },
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ const list = await this.getListFromData(data.list, data.varName, cache);
+ const varName2 = this.evalMessage(data.varName2, cache);
+ const storage2 = parseInt(data.storage, 10);
+
+ if (Array.isArray(list)) {
+ const length = list.length > 0 ? list.length : "undefined";
+ this.storeValue(length, storage2, varName2, cache);
+ } else {
+ this.storeValue("undefined", storage2, varName2, cache);
+ }
+
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
From 2756ffe93ede0f62daec2e9c004dd1f0c7aa63af Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 16:31:47 -0700
Subject: [PATCH 22/27] **Changelog**
* Created a mod version of get_list_length_MOD.js this one only returns a number for the list length and not a list like 1,2,3. this also makes it so if the list is empty or is not a list it will be undefined
---
actions/get_list_length_MOD.js | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/actions/get_list_length_MOD.js b/actions/get_list_length_MOD.js
index 6df8f81e..d27bd679 100644
--- a/actions/get_list_length_MOD.js
+++ b/actions/get_list_length_MOD.js
@@ -1,6 +1,6 @@
module.exports = {
- name: "Get List Length",
- section: "Lists and Loops",
+ name: 'Get List Length',
+ section: 'Lists and Loops',
subtitle(data, presets) {
const list = presets.lists;
@@ -10,12 +10,12 @@ module.exports = {
variableStorage(data, varType) {
const type = parseInt(data.storage, 10);
if (type !== varType) return;
- return [data.varName2, "Number"];
+ return [data.varName2, 'Number'];
},
- meta: { version: "2.1.7", preciseCheck: true, author: null, authorUrl: null, downloadUrl: null },
+ meta: { version: '2.1.7', preciseCheck: true, author: null, authorUrl: null, downloadUrl: null },
- fields: ["list", "varName", "storage", "varName2"],
+ fields: ['list', 'varName', 'storage', 'varName2'],
html(isEvent, data) {
return `
@@ -39,7 +39,7 @@ module.exports = {
init() {
const { glob, document } = this;
- glob.listChange(document.getElementById("list"), "varNameContainer");
+ glob.listChange(document.getElementById('list'), 'varNameContainer');
},
async action(cache) {
@@ -49,10 +49,10 @@ module.exports = {
const storage2 = parseInt(data.storage, 10);
if (Array.isArray(list)) {
- const length = list.length > 0 ? list.length : "undefined";
+ const length = list.length > 0 ? list.length : 'undefined';
this.storeValue(length, storage2, varName2, cache);
} else {
- this.storeValue("undefined", storage2, varName2, cache);
+ this.storeValue('undefined', storage2, varName2, cache);
}
this.callNextAction(cache);
From 48f73f3d5097d43554a1ca175cd4fab8ebbbc778 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 6 Jun 2024 16:33:09 -0700
Subject: [PATCH 23/27] Fixed Title
---
actions/get_list_length_MOD.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/actions/get_list_length_MOD.js b/actions/get_list_length_MOD.js
index d27bd679..13b1e0c7 100644
--- a/actions/get_list_length_MOD.js
+++ b/actions/get_list_length_MOD.js
@@ -1,5 +1,5 @@
module.exports = {
- name: 'Get List Length',
+ name: 'Get List Length MOD',
section: 'Lists and Loops',
subtitle(data, presets) {
From 0f2bc289de606e513c975cb2337761ca0a8f5e42 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 13 Jun 2024 14:33:41 -0700
Subject: [PATCH 24/27] Added console event action
---
events/console_event_EVT.js | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 events/console_event_EVT.js
diff --git a/events/console_event_EVT.js b/events/console_event_EVT.js
new file mode 100644
index 00000000..294e9873
--- /dev/null
+++ b/events/console_event_EVT.js
@@ -0,0 +1,37 @@
+const readline = require('readline');
+
+module.exports = {
+ name: 'Console Input',
+ isEvent: true,
+
+ fields: ['Temp Variable Name (Stores console input):'],
+
+ mod(DBM) {
+ DBM.Events = DBM.Events || {};
+ const { Bot, Actions } = DBM;
+
+ const rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout,
+ });
+
+ rl.on('line', (input) => {
+ if (Bot.$evts['Console Input']) {
+ for (const event of Bot.$evts['Console Input']) {
+ const temp = {};
+ if (event.temp) temp[event.temp] = input;
+ Actions.invokeEvent(event, null, temp);
+ }
+ }
+ });
+
+ const { onReady } = Bot;
+ Bot.onReady = function consoleInputOnReady() {
+ if (Bot.$evts['Console Input']) {
+ console.log('Console Input event is ready.');
+ }
+
+ onReady.apply(this);
+ };
+ },
+};
From a5b406ff355047444a48e82b88396b2134d12569 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Thu, 13 Jun 2024 14:47:38 -0700
Subject: [PATCH 25/27] Added console event action
---
actions/console_input_store_MOD.js | 64 ++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
create mode 100644 actions/console_input_store_MOD.js
diff --git a/actions/console_input_store_MOD.js b/actions/console_input_store_MOD.js
new file mode 100644
index 00000000..ffdc02ff
--- /dev/null
+++ b/actions/console_input_store_MOD.js
@@ -0,0 +1,64 @@
+module.exports = {
+ name: 'Store Console Input Parts',
+ section: 'Other Stuff',
+ subtitle(data) {
+ return `Store part ${data.partIndex} of console input`;
+ },
+ variableStorage(data, varType) {
+ const type = parseInt(data.storage, 10);
+ if (type !== varType) return;
+ return [data.varName, 'Text'];
+ },
+ fields: ['consoleInputVar', 'separator', 'partIndex', 'storage', 'varName'],
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ },
+ html() {
+ return `
+
+
+
+
+ Part Index
+
+
+
+
+
+
`;
+ },
+ init() {},
+ action(cache) {
+ const data = cache.actions[cache.index];
+ const consoleInputVar = this.evalMessage(data.consoleInputVar, cache);
+ const separator = this.evalMessage(data.separator, cache);
+ const partIndex = parseInt(this.evalMessage(data.partIndex, cache), 10) - 1;
+ const storage = parseInt(data.storage, 10);
+ const varName = this.evalMessage(data.varName, cache);
+
+ const consoleInput = this.getVariable(1, consoleInputVar, cache);
+ if (!consoleInput) {
+ this.callNextAction(cache);
+ return;
+ }
+
+ const parts = consoleInput.split(separator);
+ const result = parts[partIndex] ? parts[partIndex].trim() : '';
+
+ this.storeValue(result, storage, varName, cache);
+ this.callNextAction(cache);
+ },
+ mod() {},
+};
From aea10ca47f5003a9f7177457b7f3d5e29c66b5d7 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Fri, 14 Jun 2024 00:11:59 -0700
Subject: [PATCH 26/27] Added console event action
---
actions/base_convert_MOD.js | 72 -------
actions/convert_to_base64_MOD.js | 70 -------
actions/convert_to_morse_code_MOD.js | 72 -------
actions/encoder_MOD.js | 301 +++++++++++++++++++++++++++
4 files changed, 301 insertions(+), 214 deletions(-)
delete mode 100644 actions/base_convert_MOD.js
delete mode 100644 actions/convert_to_base64_MOD.js
delete mode 100644 actions/convert_to_morse_code_MOD.js
create mode 100644 actions/encoder_MOD.js
diff --git a/actions/base_convert_MOD.js b/actions/base_convert_MOD.js
deleted file mode 100644
index ffdc34a2..00000000
--- a/actions/base_convert_MOD.js
+++ /dev/null
@@ -1,72 +0,0 @@
-module.exports = {
- name: 'Base Convert MOD',
- displayName: 'Base Convert',
- section: 'Other Stuff',
- meta: {
- version: '2.1.7',
- preciseCheck: false,
- author: 'DBM Mods',
- authorUrl: 'https://github.com/dbm-network/mods',
- downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/base_convert_MOD.js',
- },
-
- subtitle(data) {
- return `Base ${data.basef} to Base ${data.baset}`;
- },
-
- variableStorage(data, varType) {
- if (parseInt(data.storage, 10) !== varType) return;
- return [data.varName, 'Number'];
- },
-
- fields: ['num', 'basef', 'baset', 'storage', 'varName'],
-
- html() {
- return `
-
- Number
-
-
-
-
-
-
-
-`;
- },
-
- init() {},
-
- async action(cache) {
- const data = cache.actions[cache.index];
- const num = this.evalMessage(data.num, cache);
- const basef = parseInt(data.basef, 10);
- const baset = parseInt(data.baset, 10);
- let result;
- if (basef > 1 && basef <= 36 && baset > 1 && baset <= 36) {
- const base = parseInt(num, basef, 10);
- if (!Number.isNaN(base)) {
- result = base.toString(baset).toUpperCase();
- } else {
- console.log(`Invalid input, ${num} not Base-${basef}`);
- }
- }
- if (result !== undefined) {
- const storage = parseInt(data.storage, 10);
- const varName = this.evalMessage(data.varName, cache);
- this.storeValue(result, storage, varName, cache);
- }
- this.callNextAction(cache);
- },
-
- mod() {},
-};
diff --git a/actions/convert_to_base64_MOD.js b/actions/convert_to_base64_MOD.js
deleted file mode 100644
index dd3dc7e4..00000000
--- a/actions/convert_to_base64_MOD.js
+++ /dev/null
@@ -1,70 +0,0 @@
-module.exports = {
- name: 'Convert to Base64',
- section: 'Other Stuff',
- meta: {
- version: '2.1.7',
- preciseCheck: false,
- author: 'DBM Mods',
- authorUrl: 'https://github.com/dbm-network/mods',
- downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/convert_to_base64_MOD.js',
- },
-
- subtitle() {
- return 'Convert To Base64';
- },
-
- variableStorage(data, varType) {
- if (parseInt(data.storage, 10) !== varType) return;
- return [data.varName, 'String'];
- },
-
- fields: ['input', 'info', 'storage', 'varName'],
-
- html() {
- return `
-
-
- Options
-
- Encode
- Decode
-
-
-
- Text or Morse Code
-
-
-
-
-
-
-
-
`;
- },
-
- init() {},
-
- async action(cache) {
- const data = cache.actions[cache.index];
- const storage = parseInt(data.storage, 10);
- const info = parseInt(data.info, 10);
- const varName = this.evalMessage(data.varName, cache);
- const input = this.evalMessage(data.input, cache);
- let result;
-
- switch (info) {
- case 0:
- result = Buffer.from(input).toString('base64');
- break;
- case 1:
- result = Buffer.from(input, 'base64').toString();
- break;
- default:
- break;
- }
- this.storeValue(result, storage, varName, cache);
- this.callNextAction(cache);
- },
-
- mod() {},
-};
diff --git a/actions/convert_to_morse_code_MOD.js b/actions/convert_to_morse_code_MOD.js
deleted file mode 100644
index 80e2f35f..00000000
--- a/actions/convert_to_morse_code_MOD.js
+++ /dev/null
@@ -1,72 +0,0 @@
-module.exports = {
- name: 'Morse Code',
- section: 'Other Stuff',
- meta: {
- version: '2.1.7',
- preciseCheck: false,
- author: 'DBM Mods',
- authorUrl: 'https://github.com/dbm-network/mods',
- downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/convert_to_morse_code_MOD.js',
- },
-
- subtitle() {
- return 'Convert To Morse Code';
- },
-
- variableStorage(data, varType) {
- if (parseInt(data.storage, 10) !== varType) return;
- return [data.varName, 'Morse Code'];
- },
-
- fields: ['input', 'info', 'storage', 'varName'],
-
- html() {
- return `
-
- Text or Morse Code:
-
-
-
-
-
- Options:
-
- Encode
- Decode
-
-
-
-
-
-
-
`;
- },
-
- init() {},
-
- async action(cache) {
- const data = cache.actions[cache.index];
- const Mods = this.getMods();
- const morse = Mods.require('morse-decoder');
- const storage = parseInt(data.storage, 10);
- const info = parseInt(data.info, 10);
- const varName = this.evalMessage(data.varName, cache);
- const input = this.evalMessage(data.input, cache);
- let result;
-
- switch (info) {
- case 0:
- result = morse.encode(input);
- break;
- case 1:
- result = morse.decode(input);
- break;
- default:
- break;
- }
- this.storeValue(result, storage, varName, cache);
- this.callNextAction(cache);
- },
-
- mod() {},
-};
diff --git a/actions/encoder_MOD.js b/actions/encoder_MOD.js
new file mode 100644
index 00000000..c54699df
--- /dev/null
+++ b/actions/encoder_MOD.js
@@ -0,0 +1,301 @@
+module.exports = {
+ name: 'Encode/Decode Text',
+ section: 'Other Stuff',
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ },
+
+ subtitle(data) {
+ const methods = [
+ 'Binary',
+ 'Keyboard Shift',
+ 'Base64',
+ 'Caesar Cipher',
+ 'Enigma Machine',
+ 'Letter to Number',
+ 'Morse Code',
+ 'Hexadecimal',
+ 'URL Encoding',
+ 'ROT13',
+ 'Vigenère Cipher',
+ ];
+ const action = data.encode === 'true' ? 'Encode' : 'Decode';
+ return `${methods[data.method]} ${action}`;
+ },
+
+ variableStorage(data, varType) {
+ if (parseInt(data.storage, 10) !== varType) return;
+ return [data.varName, 'String'];
+ },
+
+ fields: ['text', 'method', 'encode', 'shift', 'keyword', 'storage', 'varName'],
+
+ html() {
+ return `
+
+ Text
+
+
+
+ Method
+
+ Binary
+ Keyboard Shift
+ Base64
+ Caesar Cipher
+ Enigma Machine
+ Letter to Number
+ Morse Code
+ Hexadecimal
+ URL Encoding
+ ROT13
+ Vigenère Cipher
+
+
+
+ Encode or Decode
+
+ Encode
+ Decode
+
+
+
+ Shift Amount (for Caesar Cipher & Keyboard Shift)
+
+
+
+ Keyword (for Vigenère Cipher)
+
+
+
+
+
`;
+ },
+
+ /* eslint-disable */
+ init() {
+ const { document } = this;
+ const methodSelect = document.getElementById('method');
+ const shiftContainer = document.getElementById('shift-container');
+ const keywordContainer = document.getElementById('keyword-container');
+
+ function toggleContainers() {
+ const method = parseInt(methodSelect.value, 10);
+ shiftContainer.style.display = method === 1 || method === 3 ? 'block' : 'none';
+ keywordContainer.style.display = method === 10 ? 'block' : 'none';
+ }
+
+ methodSelect.addEventListener('change', toggleContainers);
+ toggleContainers();
+ },
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ const text = this.evalMessage(data.text, cache);
+ const method = parseInt(data.method, 10);
+ const encode = data.encode === 'true';
+ const shift = parseInt(data.shift, 10);
+ const keyword = this.evalMessage(data.keyword, cache);
+ let result;
+
+ switch (method) {
+ case 0: // Binary
+ result = encode
+ ? text
+ .split('')
+ .map((char) => char.charCodeAt(0).toString(2).padStart(8, '0'))
+ .join(' ')
+ : text
+ .split(' ')
+ .map((bin) => String.fromCharCode(parseInt(bin, 2)))
+ .join('');
+ break;
+ case 1: // Keyboard Shift
+ const keyboardShift = (char, shift) => {
+ const qwerty = 'qwertyuiopasdfghjklzxcvbnm';
+ const index = qwerty.indexOf(char.toLowerCase());
+ if (index === -1) return char;
+ const newIndex = (index + shift + qwerty.length) % qwerty.length;
+ return char === char.toUpperCase() ? qwerty[newIndex].toUpperCase() : qwerty[newIndex];
+ };
+ result = text
+ .split('')
+ .map((char) => keyboardShift(char, encode ? shift : -shift))
+ .join('');
+ break;
+ case 2: // Base64
+ result = encode ? Buffer.from(text).toString('base64') : Buffer.from(text, 'base64').toString('utf8');
+ break;
+ case 3: // Caesar Cipher
+ result = text
+ .split('')
+ .map((char) => {
+ if (char.match(/[a-z]/i)) {
+ const code = char.charCodeAt(0);
+ const offset = code >= 65 && code <= 90 ? 65 : 97;
+ return String.fromCharCode(((((code - offset + (encode ? shift : -shift)) % 26) + 26) % 26) + offset);
+ }
+ return char;
+ })
+ .join('');
+ break;
+ case 4: // Enigma Machine (simplified)
+ const enigma = (char, encode) => {
+ const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ const reflector = 'YRUHQSLDPXNGOKMIEBFZCWVJAT';
+ const rotor1 = 'EKMFLGDQVZNTOWYHXUSPAIBRCJ';
+ const rotor2 = 'AJDKSIRUXBLHWTMCQGZNPYFVOE';
+ const rotor3 = 'BDFHJLCPRTXVZNYEIWGAKMUSQO';
+ const rotors = [rotor1, rotor2, rotor3];
+ const reverse = (rotor) =>
+ rotor.split('').reduce((acc, val, i) => {
+ acc[val] = alphabet[i];
+ return acc;
+ }, {});
+
+ if (!alphabet.includes(char.toUpperCase())) return char;
+ let index = alphabet.indexOf(char.toUpperCase());
+ for (let i = 0; i < rotors.length; i++) {
+ index = alphabet.indexOf(rotors[i][index]);
+ }
+ index = alphabet.indexOf(reflector[index]);
+ for (let i = rotors.length - 1; i >= 0; i--) {
+ index = alphabet.indexOf(reverse(rotors[i])[index]);
+ }
+ return alphabet[index];
+ };
+ result = text
+ .split('')
+ .map((char) => enigma(char, encode))
+ .join('');
+ break;
+ case 5: // Letter to Number
+ result = encode
+ ? text
+ .split('')
+ .map((char) => char.toLowerCase().charCodeAt(0) - 96)
+ .join(' ')
+ : text
+ .split(' ')
+ .map((num) => String.fromCharCode(parseInt(num) + 96))
+ .join('');
+ break;
+ case 6: // Morse Code
+ const morseAlphabet = {
+ a: '.-',
+ b: '-...',
+ c: '-.-.',
+ d: '-..',
+ e: '.',
+ f: '..-.',
+ g: '--.',
+ h: '....',
+ i: '..',
+ j: '.---',
+ k: '-.-',
+ l: '.-..',
+ m: '--',
+ n: '-.',
+ o: '---',
+ p: '.--.',
+ q: '--.-',
+ r: '.-.',
+ s: '...',
+ t: '-',
+ u: '..-',
+ v: '...-',
+ w: '.--',
+ x: '-..-',
+ y: '-.--',
+ z: '--..',
+ 1: '.----',
+ 2: '..---',
+ 3: '...--',
+ 4: '....-',
+ 5: '.....',
+ 6: '-....',
+ 7: '--...',
+ 8: '---..',
+ 9: '----.',
+ 0: '-----',
+ '.': '.-.-.-',
+ '/': '-..-.',
+ ' ': '/',
+ };
+ if (encode) {
+ result = text
+ .toLowerCase()
+ .split('')
+ .map((char) => morseAlphabet[char] || '')
+ .join(' ');
+ } else {
+ const reversedMorseAlphabet = Object.fromEntries(Object.entries(morseAlphabet).map(([k, v]) => [v, k]));
+ result = text
+ .split(' ')
+ .map((code) => reversedMorseAlphabet[code] || '')
+ .join('');
+ }
+ break;
+ case 7: // Hexadecimal
+ result = encode
+ ? text
+ .split('')
+ .map((char) => char.charCodeAt(0).toString(16).padStart(2, '0'))
+ .join(' ')
+ : text
+ .split(' ')
+ .map((hex) => String.fromCharCode(parseInt(hex, 16)))
+ .join('');
+ break;
+ case 8: // URL Encoding
+ result = encode ? encodeURIComponent(text) : decodeURIComponent(text);
+ break;
+ case 9: // ROT13
+ result = text.replace(/[a-z]/gi, (char) => {
+ const offset = char <= 'Z' ? 65 : 97;
+ return String.fromCharCode(((char.charCodeAt(0) - offset + 13) % 26) + offset);
+ });
+ break;
+ case 10: // Vigenère Cipher
+ const vigenere = (text, keyword, encode) => {
+ const alphabet = 'abcdefghijklmnopqrstuvwxyz';
+ const shift = (char, keyChar, encode) => {
+ const charIndex = alphabet.indexOf(char.toLowerCase());
+ const keyIndex = alphabet.indexOf(keyChar.toLowerCase());
+ if (charIndex === -1 || keyIndex === -1) return char;
+ const newIndex = encode ? (charIndex + keyIndex) % 26 : (charIndex - keyIndex + 26) % 26;
+ return char === char.toUpperCase() ? alphabet[newIndex].toUpperCase() : alphabet[newIndex];
+ };
+
+ let keyIndex = 0;
+ return text
+ .split('')
+ .map((char) => {
+ if (alphabet.includes(char.toLowerCase())) {
+ const result = shift(char, keyword[keyIndex], encode);
+ keyIndex = (keyIndex + 1) % keyword.length;
+ return result;
+ }
+ return char;
+ })
+ .join('');
+ };
+
+ result = vigenere(text, keyword, encode);
+ break;
+ }
+
+ if (result !== undefined) {
+ const storage = parseInt(data.storage, 10);
+ const varName = this.evalMessage(data.varName, cache);
+ this.storeValue(result, storage, varName, cache);
+ }
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
+/* eslint-enable */
From 48561da2bb894bb69663378896e1d3efffd29a59 Mon Sep 17 00:00:00 2001
From: thekingofspace <37231416+thekingofspace@users.noreply.github.com>
Date: Fri, 14 Jun 2024 15:25:17 -0700
Subject: [PATCH 27/27] RE added the convert packages
---
actions/base_convert_MOD.js | 72 ++++++++++++++++++++++++++++
actions/convert_to_base64_MOD.js | 70 +++++++++++++++++++++++++++
actions/convert_to_morse_code_MOD.js | 72 ++++++++++++++++++++++++++++
3 files changed, 214 insertions(+)
create mode 100644 actions/base_convert_MOD.js
create mode 100644 actions/convert_to_base64_MOD.js
create mode 100644 actions/convert_to_morse_code_MOD.js
diff --git a/actions/base_convert_MOD.js b/actions/base_convert_MOD.js
new file mode 100644
index 00000000..ffdc34a2
--- /dev/null
+++ b/actions/base_convert_MOD.js
@@ -0,0 +1,72 @@
+module.exports = {
+ name: 'Base Convert MOD',
+ displayName: 'Base Convert',
+ section: 'Other Stuff',
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/base_convert_MOD.js',
+ },
+
+ subtitle(data) {
+ return `Base ${data.basef} to Base ${data.baset}`;
+ },
+
+ variableStorage(data, varType) {
+ if (parseInt(data.storage, 10) !== varType) return;
+ return [data.varName, 'Number'];
+ },
+
+ fields: ['num', 'basef', 'baset', 'storage', 'varName'],
+
+ html() {
+ return `
+
+ Number
+
+
+
+
+
+
+
+`;
+ },
+
+ init() {},
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ const num = this.evalMessage(data.num, cache);
+ const basef = parseInt(data.basef, 10);
+ const baset = parseInt(data.baset, 10);
+ let result;
+ if (basef > 1 && basef <= 36 && baset > 1 && baset <= 36) {
+ const base = parseInt(num, basef, 10);
+ if (!Number.isNaN(base)) {
+ result = base.toString(baset).toUpperCase();
+ } else {
+ console.log(`Invalid input, ${num} not Base-${basef}`);
+ }
+ }
+ if (result !== undefined) {
+ const storage = parseInt(data.storage, 10);
+ const varName = this.evalMessage(data.varName, cache);
+ this.storeValue(result, storage, varName, cache);
+ }
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
diff --git a/actions/convert_to_base64_MOD.js b/actions/convert_to_base64_MOD.js
new file mode 100644
index 00000000..dd3dc7e4
--- /dev/null
+++ b/actions/convert_to_base64_MOD.js
@@ -0,0 +1,70 @@
+module.exports = {
+ name: 'Convert to Base64',
+ section: 'Other Stuff',
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/convert_to_base64_MOD.js',
+ },
+
+ subtitle() {
+ return 'Convert To Base64';
+ },
+
+ variableStorage(data, varType) {
+ if (parseInt(data.storage, 10) !== varType) return;
+ return [data.varName, 'String'];
+ },
+
+ fields: ['input', 'info', 'storage', 'varName'],
+
+ html() {
+ return `
+
+
+ Options
+
+ Encode
+ Decode
+
+
+
+ Text or Morse Code
+
+
+
+
+
+
+
+
`;
+ },
+
+ init() {},
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ const storage = parseInt(data.storage, 10);
+ const info = parseInt(data.info, 10);
+ const varName = this.evalMessage(data.varName, cache);
+ const input = this.evalMessage(data.input, cache);
+ let result;
+
+ switch (info) {
+ case 0:
+ result = Buffer.from(input).toString('base64');
+ break;
+ case 1:
+ result = Buffer.from(input, 'base64').toString();
+ break;
+ default:
+ break;
+ }
+ this.storeValue(result, storage, varName, cache);
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};
diff --git a/actions/convert_to_morse_code_MOD.js b/actions/convert_to_morse_code_MOD.js
new file mode 100644
index 00000000..80e2f35f
--- /dev/null
+++ b/actions/convert_to_morse_code_MOD.js
@@ -0,0 +1,72 @@
+module.exports = {
+ name: 'Morse Code',
+ section: 'Other Stuff',
+ meta: {
+ version: '2.1.7',
+ preciseCheck: false,
+ author: 'DBM Mods',
+ authorUrl: 'https://github.com/dbm-network/mods',
+ downloadURL: 'https://github.com/dbm-network/mods/blob/master/actions/convert_to_morse_code_MOD.js',
+ },
+
+ subtitle() {
+ return 'Convert To Morse Code';
+ },
+
+ variableStorage(data, varType) {
+ if (parseInt(data.storage, 10) !== varType) return;
+ return [data.varName, 'Morse Code'];
+ },
+
+ fields: ['input', 'info', 'storage', 'varName'],
+
+ html() {
+ return `
+
+ Text or Morse Code:
+
+
+
+
+
+ Options:
+
+ Encode
+ Decode
+
+
+
+
+
+
+
`;
+ },
+
+ init() {},
+
+ async action(cache) {
+ const data = cache.actions[cache.index];
+ const Mods = this.getMods();
+ const morse = Mods.require('morse-decoder');
+ const storage = parseInt(data.storage, 10);
+ const info = parseInt(data.info, 10);
+ const varName = this.evalMessage(data.varName, cache);
+ const input = this.evalMessage(data.input, cache);
+ let result;
+
+ switch (info) {
+ case 0:
+ result = morse.encode(input);
+ break;
+ case 1:
+ result = morse.decode(input);
+ break;
+ default:
+ break;
+ }
+ this.storeValue(result, storage, varName, cache);
+ this.callNextAction(cache);
+ },
+
+ mod() {},
+};