add symphish command

This commit is contained in:
hgw 2023-10-04 00:35:47 +00:00
parent 53b6623ae2
commit be8377c329
Signed by: hgw
SSH Key Fingerprint: SHA256:diG7RVYHjd3aDYkZWHYcBJbImu+6zfptuUP+3k/wol4
4 changed files with 26 additions and 11 deletions

10
bot.js
View File

@ -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);

View File

@ -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)
gen(height, width, type)

6
package-lock.json generated
View File

@ -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=="
}
}
}

View File

@ -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"