From be8377c32913b25aba01948601969342d32b24c8 Mon Sep 17 00:00:00 2001 From: hgw Date: Wed, 4 Oct 2023 00:35:47 +0000 Subject: [PATCH] add symphish command --- bot.js | 10 ++++++++-- commands/phish.js | 19 ++++++++++++++----- package-lock.json | 6 +++--- package.json | 2 +- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/bot.js b/bot.js index 9d169d8..29ba8f3 100644 --- a/bot.js +++ b/bot.js @@ -81,7 +81,11 @@ async function godwords(chan, amt) { } async function phish(chan, height, width) { - openPostWorker(chan, 'phish', height, width) + openPostWorker(chan, 'phish', height, width, "em") +} + +async function symphish(chan, height, width) { + openPostWorker(chan, 'phish', height, width, "sym") } bot.addListener('message', function(nick, to, text, from) { @@ -117,7 +121,9 @@ bot.addListener('message', function(nick, to, text, from) { godwords(to, args[1]); } else if (command === config.irc.prefix+'phish') { phish(to, args[1], args[2]) - } + } else if (command === config.irc.prefix+'symphish') { + symphish(to, args[1], args[2]) + } msgTimeout.add(to); setTimeout(() => { msgTimeout.delete(to); diff --git a/commands/phish.js b/commands/phish.js index ea71708..8251814 100644 --- a/commands/phish.js +++ b/commands/phish.js @@ -1,8 +1,9 @@ const config = require('../config/config.json') const { parentPort, workerData } = require('worker_threads'); -const { d1, d2 } = workerData; +const { d1, d2, d3 } = workerData; var height = d1 var width = d2 +var type = d3 var phish = require('phishies'); const timer = ms => new Promise(res => setTimeout(res, ms)) @@ -33,6 +34,17 @@ async function sendUpstream(content) { process.exit() } +function gen(height, width, type) { + consoleLog('[phish] Generating phish output') + if (type == "em") { + var aquarium = phish.aquarium(height, width) + } else if (type == "sym") { + var aquarium = phish.aquarium_sym(height, width) + } + var output = aquarium.join("\n") + sendUpstream(output) +} + if (height > 100) { consoleLog('[phish] Height requesteed was over the maximum allowable amount, defaulting to maximum') height = 100 @@ -49,7 +61,4 @@ if (width == undefined) { consoleLog('[phish] Width was not specified, defaulting to 5') width = 7 } -consoleLog('[phish] Generating phish output') -var aquarium = phish.aquarium(height, width) -var output = aquarium.join("\n") -sendUpstream(output) \ No newline at end of file +gen(height, width, type) \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4507e8e..8602cd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,9 +49,9 @@ } }, "phishies": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/phishies/-/phishies-1.1.0.tgz", - "integrity": "sha512-pQFH3dgXdty/SZBzqXwBI0XC/jPlasiA7N/418C3sVvn00uto1KewgdvTA5Bh06mVOP4mjevfAVCEaRMcvh2kw==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/phishies/-/phishies-1.2.0.tgz", + "integrity": "sha512-1Z4Mt3es3NEkEFyYyOnVAyiDeGghh40IrAQ10lcUQbmNkoI3ZfaHomCDffir4w9x6XVjHCl21doUjCokBMry5Q==" } } } diff --git a/package.json b/package.json index 95d08ee..bb71ebf 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "fs": "^0.0.1-security", "irc": "^0.5.2", - "phishies": "^1.1.0" + "phishies": "^1.2.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1"