From 63baf493ac61ace11280398d12f89c0d40add4f7 Mon Sep 17 00:00:00 2001 From: hgw Date: Mon, 2 Oct 2023 02:14:36 +0000 Subject: [PATCH] move subfiles for commands to own folder --- bot.js | 16 ++++------------ wordgen.js => commands/godwords.js | 8 +++----- 2 files changed, 7 insertions(+), 17 deletions(-) rename wordgen.js => commands/godwords.js (64%) diff --git a/bot.js b/bot.js index 251b198..f04918c 100644 --- a/bot.js +++ b/bot.js @@ -10,7 +10,7 @@ var config = { //edit your shit here server: "irc.supernets.org", port: 6697, SSL: true, - channels: ['#dev'], + channels: ['#dev', '#superbowl'], botName: "fascinus", userName: "fascinus", realName: "Sneed" @@ -115,7 +115,6 @@ async function rspam(chan, amt) { } async function art(chan, url) { - var ext = path.extname(url) if (ext === ".png") { var filetype = "png" @@ -157,28 +156,21 @@ async function godwords(chan, amt) { if (amt > 100000) { bot.say(chan, "no") } else { - if (amt === undefined) { var amt = 50 } - //for(var i=0; i < amt; i++){ - // var word = randomWords({ exactly: 1 }); - // text.push(word); - // var string = text.join(" ") - //} - const worker = new Worker('./wordgen.js', { + const worker = new Worker('./commands/godwords.js', { workerData: { amt } }); worker.once('message', (string) => { - console.log('Received the hashedArray from the worker thread!'); + console.log('Received string from worker, posting.'); bot.say(chan, string); }); } } - bot.addListener('message', function(nick, to, text, from) { var args = text.split(' '); if (args[0] === '$help') { @@ -204,4 +196,4 @@ bot.addListener('error', function(message) { console.log('error: ', message); }); -console.log('Starting Fascinus'); +console.log('Starting Fascinus'); \ No newline at end of file diff --git a/wordgen.js b/commands/godwords.js similarity index 64% rename from wordgen.js rename to commands/godwords.js index 921250c..d61d037 100644 --- a/wordgen.js +++ b/commands/godwords.js @@ -2,7 +2,7 @@ const { parentPort, workerData } = require('worker_threads'); const { amt } = workerData; var randomWords = require('better-random-words'); -var hashedArray = []; +var output = []; var string = []; var text = []; for(var i=0; i < amt; i++){ @@ -10,9 +10,7 @@ for(var i=0; i < amt; i++){ text.push(word); } var string = text.join(" ") -hashedArray.push(string); -//console.log(string); -// send the hashedArray to the parent thread -parentPort.postMessage(hashedArray); +output.push(string); +parentPort.postMessage(output); process.exit() \ No newline at end of file