Compare commits

..

No commits in common. "e5a8baaa812e027888ac5a26f2bb5d896e857486" and "143d726dc08abef47f1a7f083d310c06a9bc1ca2" have entirely different histories.

15 changed files with 270 additions and 512 deletions

1
.gitignore vendored
View File

@ -131,4 +131,3 @@ dist
.env .env
config/config.json config/config.json
TODO

View File

@ -1,10 +1,10 @@
FROM node:18 FROM node:16
RUN apt update && apt install -y python3 python3-pip wget RUN apt update && apt install -y python3 python3-pip wget
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app WORKDIR /home/node/app
USER node USER node
COPY --chown=node:node lib/banter/requirements.txt . COPY --chown=node:node lib/banter/requirements.txt .
RUN pip3 install -r requirements.txt --break-system-packages RUN pip3 install -r requirements.txt
COPY --chown=node:node package*.json ./ COPY --chown=node:node package*.json ./
RUN npm i RUN npm i
COPY --chown=node:node . . COPY --chown=node:node . .

209
bot.js
View File

@ -1,13 +1,11 @@
var config = require('./config/config.json') var config = require('./config/config.json')
var irc = require("irc"); var irc = require("irc");
var fs = require("fs");
var readline = require('readline');
var path = require('path');
var randomext = require('./lib/randomnum');
const { Worker } = require('worker_threads'); const { Worker } = require('worker_threads');
//var randomWords = require('better-random-words');
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
const msgTimeout = new Set();
const msgTimeoutMsg = new Set();
const timer = ms => new Promise(res => setTimeout(res, ms))
var hostmask = null
var bot = new irc.Client(config.irc.server, config.irc.nickname, { var bot = new irc.Client(config.irc.server, config.irc.nickname, {
channels: config.irc.channels, channels: config.irc.channels,
@ -20,28 +18,56 @@ var bot = new irc.Client(config.irc.server, config.irc.nickname, {
floodProtectionDelay: config.floodprotect.flood_protection_delay floodProtectionDelay: config.floodprotect.flood_protection_delay
}); });
function consoleLog(log) { const msgTimeout = new Set();
if (config.misc.logging === "true") { const msgTimeoutMsg = new Set();
console.log(log)
const timer = ms => new Promise(res => setTimeout(res, ms))
const generateRandomString = (amt) => {
const chars =
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890`!@#$%^&*()_+{}|\"\',./ᘈᷞኬᲡ᩶ᐨᅚ⸗⡳ᾟⓅᤲ⧛ሥ⸰⯠ᬨ⧻Შ⼷ᢕ᭄◁ⱉጻ៾᪅⎑ᘂᏤ⛰⃡";
const randomArray = Array.from(
{ length: amt },
(v, k) => chars[Math.floor(Math.random() * chars.length)]
);
const randomString = randomArray.join("");
return randomString;
}
async function help(chan) {
bot.say(chan, 'Fascinus - https://git.supernets.org/hogwart7/fascinus')
bot.say(chan, "$flood [AMOUNT (max=10000)] [TEXT] - Floods the channel with a specific line x amount of times")
bot.say(chan, "$ctcpflood [TARGET] [TEXT (one word)] [AMOUNT] - Sends x amount of CTCP requests to a target.")
bot.say(chan, "$sneed - Pastes the Sneed's Feed and Seed copypasta.")
bot.say(chan, "$rspam [LINES (def=100, max=10000)] - Spams x lines of random characters")
bot.say(chan, "$uspam [LINES (def=100, max=10000)] - Spams x lines of random unicode characters of varying length")
bot.say(chan, "$art [IMAGE URL (png/jpg/webp/jpeg)] - Creates IRC art using a source image.")
bot.say(chan, "$godwords [AMOUNT (def=50, max=100000)] - Generate x amount of random words. Inspired by TempleOS.")
}
async function flood(chan, arg) {
arg.shift() //$flood
let amt = arg.shift() //number
var text = arg.join(" ")
if (amt > 100000) {
bot.say(chan, "no");
} else { } else {
return; for(var i=0; i < amt; i++){
bot.say(chan, text);
}
} }
} }
function openPostWorker(chan, command, d1, d2, d3, d4, d5, d6) { async function sneed(chan) {
consoleLog(`[bot.openPostWorker] Opening ${command} worker`) bot.say(chan, 'THE SIGN IS A SUBTLE JOKE. THE SHOP IS CALLED \"SNEED\'S FEED & SEED\", WHERE')
const worker = new Worker(`./commands/${command}.js`, { bot.say(chan, 'FEED AND SEED BOTH END IN THE SOUND "-EED", THUS RHYMING WITH THE NAME OF')
workerData: { bot.say(chan, 'THE OWNER, SNEED. THE SIGN SAYS THAT THE SHOP WAS "FORMERLY CHUCK\'S", IMPLYING')
d1, d2, d3, d4, d5, d6 //d1-d6 equate to variables you can pass in to a worker, see the example1 block below for an example (var1 there is d1 here). Further defined in individual command files. bot.say(chan, 'THAT THE TWO WORDS BEGINNING WITH "F" AND "S" WOULD HAVE ENDED WITH "-UCK",')
} bot.say(chan, 'RHYMING WITH "CHUCK". SO, WHEN CHUCK OWNED THE SHOP, IT WOULD HAVE BEEN CALLED')
}); bot.say(chan, '"CHUCK\'S FUCK AND SUCK".')
worker.once('message', (string) => {
consoleLog(`[bot.openPostWorker.finalising] Got output from ${command}, sending to `+chan);
bot.say(chan, string);
});
} }
async function ctcp(target, text, amt) { //This can not be moved to its own file due to the nature of how it works async function ctcp(target, text, amt) {
if (amt > 10000) { if (amt > 10000) {
bot.say(chan, "no"); bot.say(chan, "no");
} else { } else {
@ -52,37 +78,123 @@ async function ctcp(target, text, amt) { //This can not be moved to its own file
} }
} }
async function help(chan) {
openPostWorker(chan, 'help')
}
async function flood(chan, arg) {
openPostWorker(chan, 'flood', arg)
}
async function sneed(chan) {
openPostWorker(chan, 'sneed')
}
async function uspam(chan, amt) { async function uspam(chan, amt) {
openPostWorker(chan, 'uspam', amt) var arr = [];
if (amt > 10000) {
bot.say(chan, "no")
} else {
if (amt === undefined) {
var amt = 100
}
for(var i=0; i < amt; i++){
var string = "" + randomext.integer(9,0) + "," + randomext.integer(9,0) + randomext.uString(120,60);
await timer(2);
arr.push(string)
}
var output = arr.join("\n")
bot.say(chan, output);
}
} }
async function rspam(chan, amt) { async function rspam(chan, amt) {
openPostWorker(chan, 'rspam', amt) var arr = []
if (amt > 10000) {
bot.say(chan, "no")
} else {
if (amt === undefined) {
var amt = 100
}
for(var i=0; i < amt; i++){
var string = generateRandomString(70);
await timer(2);
arr.push(string)
}
var output = arr.join("\n")
bot.say(chan, output);
}
} }
async function art(chan, url) { async function art(chan, url) {
openPostWorker(chan, 'art', url) var ext = path.extname(url)
if (ext === ".png") {
var filetype = "png"
} else if (ext === ".jpg") {
var filetype = "jpg"
} else if (ext === ".webp") {
var filetype = "webp"
} else if (ext === ".jpeg") {
var filetype = "jpeg"
} else {
bot.say(chan, "Image must be PNG, JPG, JPEG, WEBP");
return
}
console.log("Starting Banter")
const spawn = require("child_process").spawn;
const pythonProcess = spawn('python3', ["lib/banter/banter.py", url, "-t", filetype])
pythonProcess.stdout.on('data', (data) => {
console.log(data.toString())
});
await timer(5000);
fs.stat('output.txt', function(err, stat) {
if (err == null) {
console.log('File exists');
const rl = readline.createInterface({
input: fs.createReadStream('output.txt'),
crlfDelay: Infinity,
});
rl.on('line', (line) => {
bot.say(chan, line);
});
} else if (err.code === 'ENOENT') {
console.log(err);
bot.say(chan, "Error")
} else {
bot.say(chan, "Other Error")
}
});
} }
async function godwords(chan, amt) { async function godwords(chan, amt) {
openPostWorker(chan, 'godwords', amt) if (amt > 100000) {
bot.say(chan, "no")
} else {
if (amt === undefined) {
var amt = 50
}
const worker = new Worker('./commands/godwords.js', {
workerData: {
amt
}
});
worker.once('message', (string) => {
console.log('Received string from worker, posting.');
bot.say(chan, string);
});
}
} }
async function phish(chan, height, width) { bot.addListener('message', function(nick, to, text, from) {
openPostWorker(chan, 'phish', height, width) var args = text.split(' ');
if (args[0] === '$help') {
help(to);
} else if (args[0] === '$flood') {
flood(to, args)
} else if (args[0] === '$sneed') {
sneed(to);
} else if (args[0] === '$ctcpflood') {
ctcp(args[1], args[2], args[3]);
} else if (args[0] === '$rspam') {
rspam(to, args[1])
} else if (args[0] === '$uspam') {
uspam(to, args[1]);
} else if (args[0] === '$art') {
art(to, args[1]);
} else if (args[0] === 'fart') {
art(to, args[1]);
} else if (args[0] === '$godwords') {
godwords(to, args[1]);
} }
});
bot.addListener('message', function(nick, to, text, from) { bot.addListener('message', function(nick, to, text, from) {
if (text.startsWith(config.irc.prefix)) { if (text.startsWith(config.irc.prefix)) {
@ -113,10 +225,10 @@ bot.addListener('message', function(nick, to, text, from) {
uspam(to, args[1]); uspam(to, args[1]);
} else if (command === config.irc.prefix+'art') { } else if (command === config.irc.prefix+'art') {
art(to, args[1]); art(to, args[1]);
} else if (command === config.irc.prefix+'fart') {
art(to, args[1]);
} else if (command === config.irc.prefix+'godwords') { } else if (command === config.irc.prefix+'godwords') {
godwords(to, args[1]); godwords(to, args[1]);
} else if (command === config.irc.prefix+'phish') {
phish(to, args[1], args[2])
} }
msgTimeout.add(to); msgTimeout.add(to);
setTimeout(() => { setTimeout(() => {
@ -128,14 +240,7 @@ bot.addListener('message', function(nick, to, text, from) {
bot.addListener('error', function(message) { bot.addListener('error', function(message) {
consoleLog('[ERROR]' +message) //Dump errors to console console.log('error: ', message);
}); });
process.on('uncaughtException', function (err) { console.log('Starting Fascinus');
console.error(err);
if (config.errorhandling.log_errors_to_irc == 'true') { //If logging errors to IRC is enabled then we send the error to that, otherwise we only consoleLog it
bot.say(config.errorhandling.error_channel, errorMsg+" "+err.stack.split('\n',1).join(" "))
}
});
consoleLog('Starting Fascinus');

View File

@ -1,60 +0,0 @@
const config = require('../config/config.json')
const { parentPort, workerData } = require('worker_threads');
const { d1 } = workerData;
var url = d1
var path = require('path');
const timer = ms => new Promise(res => setTimeout(res, ms))
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
function consoleLog(log) {
if (config.misc.logging === "true") {
console.log(log)
} else {
return;
}
}
function errorMessage(error, code, extra) {
consoleLog('[art.errorMessage] '+error.code)
if (code == "ENOENT") {
var error = errorMsg+" ENOENT"
} else {
var error = errorMsg+" Unknown error"
}
parentPort.postMessage(error);
process.exit()
}
async function sendUpstream(content) {
parentPort.postMessage(content);
process.exit()
}
async function generate(url) {
output = []
var ext = path.extname(url)
if (ext === ".png") {
var filetype = "png"
} else if (ext === ".jpg") {
var filetype = "jpg"
} else if (ext === ".webp") {
var filetype = "webp"
} else if (ext === ".jpeg") {
var filetype = "jpeg"
} else {
consoleLog('[art] Invalid image passed')
sendUpstream(errorMsg+" Image must be PNG, JPG, JPEG, WEBP");
}
consoleLog("[art] Starting banter.py process")
const spawn = require("child_process").spawn;
const pythonProcess = spawn('python3', ["/home/node/app/lib/banter/banter.py", url, "-t", filetype])
pythonProcess.stdout.on('data', (data) => {
output.push(data.toString())
});
await timer(5000);
sendUpstream(output.join('\n'))
}
generate(url)

View File

@ -1,50 +0,0 @@
const { error } = require('console');
const config = require('../config/config.json')
const { parentPort, workerData } = require('worker_threads');
const { d1 } = workerData; //Declare all used variables here (if you only pass 1 variable to this command you only really need d1 in here, but it doesnt matter)
var arg = d1; // Declaring d1 as var1, just for consistancy with the last file but again, this may not be necessary in all cases.
const timer = ms => new Promise(res => setTimeout(res, ms))
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
function consoleLog(log) {
if (config.misc.logging === "true") {
console.log(log)
} else {
return;
}
}
function errorMessage(error, code, extra) {
consoleLog('[uspam.errorMessage] '+error.code)
if (code == "BAD") {
var error = errorMsg+" SHITS_FUCKED_MAN: " + extra + " not found"
} else if (code == "TOOLARGE") {
var error = errorMsg+" Your request is too large (Maximum is 100000)"
} else {
var error = errorMsg+" Unknown error"
}
parentPort.postMessage(error);
process.exit()
}
async function sendUpstream(content) {
parentPort.postMessage(content);
process.exit()
}
var arr = []
arg.shift() //$flood
var amt = arg.shift() //number
var text = arg.join(" ")
if (amt > 100000) {
consoleLog('[flood] Request too large was made, killing worker')
errorMessage("error", "TOOLARGE")
} else {
for(var i=0; i < amt; i++){
arr.push(text)
}
}
var output = arr.join("\n")
sendUpstream(output)

View File

@ -1,41 +1,7 @@
const config = require('../config/config.json')
const { parentPort, workerData } = require('worker_threads'); const { parentPort, workerData } = require('worker_threads');
const { d1 } = workerData; const { amt } = workerData;
var amt = d1
var randomWords = require('../lib/randomword'); var randomWords = require('../lib/randomword');
const timer = ms => new Promise(res => setTimeout(res, ms))
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
function consoleLog(log) {
if (config.misc.logging === "true") {
console.log(log)
} else {
return;
}
}
function errorMessage(error, code, extra) {
consoleLog('[godwords.errorMessage] '+error.code)
if (code == "BAD") {
var error = errorMsg+" SHITS_FUCKED_MAN: " + extra + " not found"
} else if (code == "TOOLARGE") {
var error = errorMsg+" Your request is too large (Maximum is 10000)"
} else {
var error = errorMsg+" Unknown error"
}
parentPort.postMessage(error);
process.exit()
}
async function sendUpstream(content) {
parentPort.postMessage(content);
process.exit()
}
function gen(amt) {
consoleLog('[godwords.gen] Generating godwords output')
var output = []; var output = [];
var string = []; var string = [];
var text = []; var text = [];
@ -44,16 +10,7 @@ function gen(amt) {
text.push(word); text.push(word);
} }
var string = text.join(" ") var string = text.join(" ")
output.push(string);
sendUpstream(output);
}
if (amt > 10000) { output.push(string);
consoleLog('[godwords] Request too large was made, killing worker') parentPort.postMessage(output);
errorMessage("error", "TOOLARGE") process.exit()
} else {
if (amt === undefined) {
var amt = 50
}
gen(amt)
}

View File

@ -1,43 +0,0 @@
const config = require('../config/config.json')
const { parentPort, workerData } = require('worker_threads');
const timer = ms => new Promise(res => setTimeout(res, ms))
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
function consoleLog(log) {
if (config.misc.logging === "true") {
console.log(log)
} else {
return;
}
}
function errorMessage(error, code, extra) {
consoleLog('[help.errorMessage] '+error.code)
if (code == "BAD") {
var error = errorMsg+" SHITS_FUCKED_MAN: " + extra + " not found"
} else {
var error = errorMsg+" Unknown error"
}
parentPort.postMessage(error);
process.exit()
}
async function sendUpstream(content) {
parentPort.postMessage(content);
process.exit()
}
var output = []
output.push('Fascinus - https://git.supernets.org/hgw/fascinus')
output.push("$flood [AMOUNT (max=10000)] [TEXT] - Floods the channel with a specific line x amount of times")
output.push("$ctcpflood [TARGET] [TEXT (one word)] [AMOUNT] - Sends x amount of CTCP requests to a target.")
output.push("$sneed - Pastes the Sneed's Feed and Seed copypasta.")
output.push("$rspam [LINES (def=100, max=10000)] - Spams x lines of random characters")
output.push("$uspam [LINES (def=100, max=10000)] - Spams x lines of random unicode characters of varying length")
output.push("$art [IMAGE URL (png/jpg/webp/jpeg)] - Creates IRC art using a source image.")
output.push("$godwords [AMOUNT (def=50, max=100000)] - Generate x amount of random words. Inspired by TempleOS.")
output.push("$phish [HEIGHT (opt, max=100)] [WIDTH (opt, max=100)] - Generate an aquarium")
sendUpstream(output.join('\n'))

View File

@ -1,55 +0,0 @@
const config = require('../config/config.json')
const { parentPort, workerData } = require('worker_threads');
const { d1, d2 } = workerData;
var height = d1
var width = d2
var phish = require('phishies');
const timer = ms => new Promise(res => setTimeout(res, ms))
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
function consoleLog(log) {
if (config.misc.logging === "true") {
console.log(log)
} else {
return;
}
}
function errorMessage(error, code, extra) {
consoleLog('[phish.errorMessage] '+error.code)
if (code == "BAD") {
var error = errorMsg+" SHITS_FUCKED_MAN: " + extra + " not found"
} else {
var error = errorMsg+" Unknown error"
}
parentPort.postMessage(error);
process.exit()
}
async function sendUpstream(content) {
parentPort.postMessage(content);
process.exit()
}
if (height > 100) {
consoleLog('[phish] Height requesteed was over the maximum allowable amount, defaulting to maximum')
height = 100
}
if (width > 100) {
consoleLog('[phish] Width requesteed was over the maximum allowable amount, defaulting to maximum')
width = 100
}
if (height == undefined) {
consoleLog('[phish] Height was not specified, defaulting to 5')
height = 5
}
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)

View File

@ -1,64 +0,0 @@
const { error } = require('console');
const config = require('../config/config.json')
const { parentPort, workerData } = require('worker_threads');
const { d1 } = workerData; //Declare all used variables here (if you only pass 1 variable to this command you only really need d1 in here, but it doesnt matter)
var amt = d1; // Declaring d1 as var1, just for consistancy with the last file but again, this may not be necessary in all cases.
const timer = ms => new Promise(res => setTimeout(res, ms))
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
function consoleLog(log) {
if (config.misc.logging === "true") {
console.log(log)
} else {
return;
}
}
function errorMessage(error, code, extra) {
consoleLog('[rspam.errorMessage] '+error.code)
if (code == "BAD") {
var error = errorMsg+" SHITS_FUCKED_MAN: " + extra + " not found"
} else if (code == "TOOLARGE") {
var error = errorMsg+" Your request is too large (Maximum is 10000)"
} else {
var error = errorMsg+" Unknown error"
}
parentPort.postMessage(error);
process.exit()
}
async function sendUpstream(content) {
parentPort.postMessage(content);
process.exit()
}
const generateRandomString = (amt) => {
const chars =
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890`!@#$%^&*()_+{}|\"\',./ᘈᷞኬᲡ᩶ᐨᅚ⸗⡳ᾟⓅᤲ⧛ሥ⸰⯠ᬨ⧻Შ⼷ᢕ᭄◁ⱉጻ៾᪅⎑ᘂᏤ⛰⃡";
const randomArray = Array.from(
{ length: amt },
(v, k) => chars[Math.floor(Math.random() * chars.length)]
);
const randomString = randomArray.join("");
return randomString;
}
var arr = []
if (amt > 10000) {
consoleLog('[rpsam] Request too large was made, killing worker')
errorMessage("error", "TOOLARGE")
} else {
if (amt === undefined) {
consoleLog('[rspam] Amount was not defined, defaulting to 100')
var amt = 100
}
for(var i=0; i < amt; i++){
var string = generateRandomString(70);
timer(2);
arr.push(string)
}
var output = arr.join("\n")
sendUpstream(output)
}

View File

@ -1,39 +0,0 @@
const config = require('../config/config.json')
const { parentPort, workerData } = require('worker_threads');
const timer = ms => new Promise(res => setTimeout(res, ms))
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
function consoleLog(log) {
if (config.misc.logging === "true") {
console.log(log)
} else {
return;
}
}
function errorMessage(error, code, extra) {
consoleLog('[sneed.errorMessage] '+error.code)
if (code == "BAD") {
var error = errorMsg+" SHITS_FUCKED_MAN: " + extra + " not found"
} else {
var error = errorMsg+" Unknown error"
}
parentPort.postMessage(error);
process.exit()
}
async function sendUpstream(content) {
parentPort.postMessage(content);
process.exit()
}
output = []
output.push('THE SIGN IS A SUBTLE JOKE. THE SHOP IS CALLED \"SNEED\'S FEED & SEED\", WHERE')
output.push('FEED AND SEED BOTH END IN THE SOUND "-EED", THUS RHYMING WITH THE NAME OF')
output.push('THE OWNER, SNEED. THE SIGN SAYS THAT THE SHOP WAS "FORMERLY CHUCK\'S", IMPLYING')
output.push('THAT THE TWO WORDS BEGINNING WITH "F" AND "S" WOULD HAVE ENDED WITH "-UCK",')
output.push('RHYMING WITH "CHUCK". SO, WHEN CHUCK OWNED THE SHOP, IT WOULD HAVE BEEN CALLED')
output.push('"CHUCK\'S FUCK AND SUCK".')
sendUpstream(output.join("\n"))

View File

@ -1,65 +0,0 @@
const { error } = require('console');
const config = require('../config/config.json')
const { parentPort, workerData } = require('worker_threads');
const { d1 } = workerData; //Declare all used variables here (if you only pass 1 variable to this command you only really need d1 in here, but it doesnt matter)
var amt = d1; // Declaring d1 as var1, just for consistancy with the last file but again, this may not be necessary in all cases.
const timer = ms => new Promise(res => setTimeout(res, ms))
var randomext = require('../lib/randomnum');
warningMsg = ''+config.colours.brackets+'['+config.colours.warning+'WARNING'+config.colours.brackets+']'
errorMsg = ''+config.colours.brackets+'['+config.colours.error+'ERROR'+config.colours.brackets+']'
function consoleLog(log) {
if (config.misc.logging === "true") {
console.log(log)
} else {
return;
}
}
function errorMessage(error, code, extra) {
consoleLog('[uspam.errorMessage] '+error.code)
if (code == "BAD") {
var error = errorMsg+" SHITS_FUCKED_MAN: " + extra + " not found"
} else if (code == "TOOLARGE") {
var error = errorMsg+" Your request is too large (Maximum is 10000)"
} else {
var error = errorMsg+" Unknown error"
}
parentPort.postMessage(error);
process.exit()
}
async function sendUpstream(content) {
parentPort.postMessage(content);
process.exit()
}
const generateRandomString = (amt) => {
const chars =
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890`!@#$%^&*()_+{}|\"\',./ᘈᷞኬᲡ᩶ᐨᅚ⸗⡳ᾟⓅᤲ⧛ሥ⸰⯠ᬨ⧻Შ⼷ᢕ᭄◁ⱉጻ៾᪅⎑ᘂᏤ⛰⃡";
const randomArray = Array.from(
{ length: amt },
(v, k) => chars[Math.floor(Math.random() * chars.length)]
);
const randomString = randomArray.join("");
return randomString;
}
var arr = []
if (amt > 10000) {
consoleLog('[uspam] Request too large was made, killing worker')
errorMessage("error", "TOOLARGE")
} else {
if (amt === undefined) {
consoleLog('[uspam] Amount was not defined, defaulting to 100')
var amt = 100
}
for(var i=0; i < amt; i++){
var string = "" + randomext.integer(9,0) + "," + randomext.integer(9,0) + randomext.uString(120,60);
timer(2);
arr.push(string)
}
var output = arr.join("\n")
sendUpstream(output)
}

View File

@ -16,18 +16,5 @@
"flood_protection": "false", "flood_protection": "false",
"flood_protection_delay": "0", "flood_protection_delay": "0",
"command_listen_timeout": "2500" "command_listen_timeout": "2500"
},
"errorhandling": {
"error_logging": "true",
"error_channel": "#CHANNELTOSENDERRORSTO",
"error_channel_pass": ""
},
"colours": {
"warning": "08",
"error": "04",
"brackets": "15"
},
"misc": {
"logging": "true"
} }
} }

View File

@ -14,14 +14,34 @@ import glob, os
import requests import requests
def main(imgPath, delay, ASCIIWIDTH, COLORCHAR, FILLER, fileType): def main(imgPath, delay, ASCIIWIDTH, COLORCHAR, FILLER, fileType):
if os.path.exists("image."+fileType): if os.path.exists("image.png"):
os.remove("image."+fileType) os.remove("image.png")
if os.path.exists("image.jpg"):
os.remove("image.jpg")
if os.path.exists("image.webp"):
os.remove("image.webp")
if os.path.exists("image.jpeg"):
os.remove("image.jpeg")
if os.path.exists("output.txt"):
os.remove("output.txt")
if validators.url(imgPath) == True: if validators.url(imgPath) == True:
print('URL')
print('Downloading image to ' + "/home/node/app/image." + fileType)
#wget.download(imgPath, "/home/node/app/image." + fileType)
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0) Gecko/20100101 Firefox/101.0'} headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0) Gecko/20100101 Firefox/101.0'}
imagefile = requests.get(imgPath, headers=headers) imagefile = requests.get(imgPath, headers=headers)
open("/home/node/app/image." + fileType, "wb").write(imagefile.content) open("/home/node/app/image." + fileType, "wb").write(imagefile.content)
if fileType == "png":
print('PNG')
imgPath = "/home/node/app/image.png"
if fileType == "jpg":
print('JPG')
imgPath = "/home/node/app/image.jpg"
if fileType == "webp":
print('WEBP')
imgPath = "/home/node/app/image.webp"
im = Image.open("/home/node/app/image."+fileType, 'r') im = Image.open(imgPath, 'r')
im = ImageOps.scale(im, ASCIIWIDTH / im.width) im = ImageOps.scale(im, ASCIIWIDTH / im.width)
width, height = im.size width, height = im.size
pixel_values = list(im.getdata()) pixel_values = list(im.getdata())
@ -43,6 +63,8 @@ def main(imgPath, delay, ASCIIWIDTH, COLORCHAR, FILLER, fileType):
currentPixel+=1 currentPixel+=1
print("".join(line)) print("".join(line))
with open("output.txt", "a") as f:
print("".join(line), file=f)
if delay: if delay:
time.sleep(delay) time.sleep(delay)
sys.stdout.flush() sys.stdout.flush()

77
package-lock.json generated
View File

@ -1,8 +1,78 @@
{ {
"name": "fascinus", "name": "fascinus",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": {
"": {
"name": "fascinus",
"version": "1.0.0",
"dependencies": {
"fs": "^0.0.1-security",
"irc": "^0.5.2"
}
},
"node_modules/fs": {
"version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
},
"node_modules/iconv": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/iconv/-/iconv-2.2.3.tgz",
"integrity": "sha1-4ITWDut9c9p/CpwJbkyKvgkL+u0=",
"hasInstallScript": true,
"optional": true,
"dependencies": {
"nan": "^2.3.5"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/irc": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/irc/-/irc-0.5.2.tgz",
"integrity": "sha1-NxT0doNlqW0LL3dryRFmvrJGS7w=",
"dependencies": {
"irc-colors": "^1.1.0"
},
"engines": {
"node": ">=0.10.0"
},
"optionalDependencies": {
"iconv": "~2.2.1",
"node-icu-charset-detector": "~0.2.0"
}
},
"node_modules/irc-colors": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/irc-colors/-/irc-colors-1.5.0.tgz",
"integrity": "sha512-HtszKchBQTcqw1DC09uD7i7vvMayHGM1OCo6AHt5pkgZEyo99ClhHTMJdf+Ezc9ovuNNxcH89QfyclGthjZJOw==",
"engines": {
"node": ">=6"
}
},
"node_modules/nan": {
"version": "2.17.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz",
"integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==",
"optional": true
},
"node_modules/node-icu-charset-detector": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/node-icu-charset-detector/-/node-icu-charset-detector-0.2.0.tgz",
"integrity": "sha1-wjINo3Tdy2cfxUy0oOBB4Vb/1jk=",
"hasInstallScript": true,
"optional": true,
"dependencies": {
"nan": "^2.3.3"
},
"engines": {
"node": ">=0.6"
}
}
},
"dependencies": { "dependencies": {
"fs": { "fs": {
"version": "0.0.1-security", "version": "0.0.1-security",
@ -47,11 +117,6 @@
"requires": { "requires": {
"nan": "^2.3.3" "nan": "^2.3.3"
} }
},
"phishies": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/phishies/-/phishies-1.0.2.tgz",
"integrity": "sha512-uZArCHgYfx7GfpPGUJiQL+eh+6ksj5KGz5n9gJMjbfdk5KJEh+UZGNe4qTgmZGqeFR9NVAaL18+cebsfE7D02g=="
} }
} }
} }

View File

@ -5,8 +5,7 @@
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"irc": "^0.5.2", "irc": "^0.5.2"
"phishies": "^1.0.2"
}, },
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"