2023-10-02 02:14:37 +00:00
|
|
|
|
var config = require('./config/config.json')
|
2023-10-02 02:14:35 +00:00
|
|
|
|
var irc = require("irc");
|
|
|
|
|
var fs = require("fs");
|
2023-10-02 02:14:36 +00:00
|
|
|
|
var readline = require('readline');
|
|
|
|
|
var path = require('path');
|
2023-10-02 02:14:36 +00:00
|
|
|
|
var randomext = require('./lib/randomnum');
|
2023-10-02 02:14:36 +00:00
|
|
|
|
const { Worker } = require('worker_threads');
|
|
|
|
|
//var randomWords = require('better-random-words');
|
2023-10-02 02:14:35 +00:00
|
|
|
|
|
2023-10-02 02:14:37 +00:00
|
|
|
|
var bot = new irc.Client(config.irc.server, config.irc.nickname, {
|
|
|
|
|
channels: config.irc.channels,
|
|
|
|
|
secure: config.irc.ssl,
|
|
|
|
|
port: config.irc.port,
|
|
|
|
|
autoRejoin: config.irc.autorejoin,
|
|
|
|
|
userName: config.irc.username,
|
|
|
|
|
realName: config.irc.realname,
|
|
|
|
|
floodProtection: config.floodprotect.flood_protection,
|
|
|
|
|
floodProtectionDelay: config.floodprotect.flood_protection_delay
|
2023-10-02 02:14:35 +00:00
|
|
|
|
});
|
|
|
|
|
|
2023-10-02 02:14:37 +00:00
|
|
|
|
const msgTimeout = new Set();
|
|
|
|
|
const msgTimeoutMsg = new Set();
|
|
|
|
|
|
2023-10-02 02:14:35 +00:00
|
|
|
|
const timer = ms => new Promise(res => setTimeout(res, ms))
|
|
|
|
|
|
2023-10-02 02:14:35 +00:00
|
|
|
|
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) {
|
2023-10-02 02:14:37 +00:00
|
|
|
|
bot.say(chan, 'Fascinus - https://git.supernets.org/hogwart7/fascinus')
|
2023-10-02 02:14:37 +00:00
|
|
|
|
bot.say(chan, "$flood [AMOUNT (max=10000)] [TEXT] - Floods the channel with a specific line x amount of times")
|
2023-10-02 02:14:35 +00:00
|
|
|
|
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.")
|
2023-10-02 02:14:37 +00:00
|
|
|
|
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")
|
2023-10-02 02:14:37 +00:00
|
|
|
|
bot.say(chan, "$art [IMAGE URL (png/jpg/webp/jpeg)] - Creates IRC art using a source image.")
|
2023-10-02 02:14:36 +00:00
|
|
|
|
bot.say(chan, "$godwords [AMOUNT (def=50, max=100000)] - Generate x amount of random words. Inspired by TempleOS.")
|
2023-10-02 02:14:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-02 02:14:36 +00:00
|
|
|
|
async function flood(chan, arg) {
|
|
|
|
|
arg.shift() //$flood
|
|
|
|
|
let amt = arg.shift() //number
|
|
|
|
|
var text = arg.join(" ")
|
2023-10-02 02:14:35 +00:00
|
|
|
|
if (amt > 100000) {
|
2023-10-02 02:14:35 +00:00
|
|
|
|
bot.say(chan, "no");
|
|
|
|
|
} else {
|
|
|
|
|
for(var i=0; i < amt; i++){
|
|
|
|
|
bot.say(chan, text);
|
|
|
|
|
}
|
2023-10-02 02:14:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function sneed(chan) {
|
|
|
|
|
bot.say(chan, 'THE SIGN IS A SUBTLE JOKE. THE SHOP IS CALLED \"SNEED\'S FEED & SEED\", WHERE')
|
|
|
|
|
bot.say(chan, 'FEED AND SEED BOTH END IN THE SOUND "-EED", THUS RHYMING WITH THE NAME OF')
|
|
|
|
|
bot.say(chan, 'THE OWNER, SNEED. THE SIGN SAYS THAT THE SHOP WAS "FORMERLY CHUCK\'S", IMPLYING')
|
|
|
|
|
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".')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function ctcp(target, text, amt) {
|
2023-10-02 02:14:37 +00:00
|
|
|
|
if (amt > 10000) {
|
2023-10-02 02:14:35 +00:00
|
|
|
|
bot.say(chan, "no");
|
|
|
|
|
} else {
|
|
|
|
|
for(var i=0; i < amt; i++){
|
|
|
|
|
bot.ctcp(target, "privmsg", text);
|
|
|
|
|
await timer(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-02 02:14:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-02 02:14:36 +00:00
|
|
|
|
async function uspam(chan, amt) {
|
2023-10-02 02:14:37 +00:00
|
|
|
|
var arr = [];
|
|
|
|
|
if (amt > 10000) {
|
2023-10-02 02:14:35 +00:00
|
|
|
|
bot.say(chan, "no")
|
|
|
|
|
} else {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
if (amt === undefined) {
|
|
|
|
|
var amt = 100
|
|
|
|
|
}
|
2023-10-02 02:14:35 +00:00
|
|
|
|
for(var i=0; i < amt; i++){
|
2023-10-02 02:14:36 +00:00
|
|
|
|
var string = "" + randomext.integer(9,0) + "," + randomext.integer(9,0) + randomext.uString(120,60);
|
2023-10-02 02:14:36 +00:00
|
|
|
|
await timer(2);
|
2023-10-02 02:14:37 +00:00
|
|
|
|
arr.push(string)
|
|
|
|
|
}
|
|
|
|
|
var output = arr.join("\n")
|
|
|
|
|
bot.say(chan, output);
|
2023-10-02 02:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function rspam(chan, amt) {
|
2023-10-02 02:14:37 +00:00
|
|
|
|
var arr = []
|
|
|
|
|
if (amt > 10000) {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
bot.say(chan, "no")
|
|
|
|
|
} else {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
if (amt === undefined) {
|
|
|
|
|
var amt = 100
|
|
|
|
|
}
|
2023-10-02 02:14:36 +00:00
|
|
|
|
for(var i=0; i < amt; i++){
|
|
|
|
|
var string = generateRandomString(70);
|
2023-10-02 02:14:36 +00:00
|
|
|
|
await timer(2);
|
2023-10-02 02:14:37 +00:00
|
|
|
|
arr.push(string)
|
|
|
|
|
}
|
|
|
|
|
var output = arr.join("\n")
|
|
|
|
|
bot.say(chan, output);
|
2023-10-02 02:14:35 +00:00
|
|
|
|
}
|
2023-10-02 02:14:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-02 02:14:36 +00:00
|
|
|
|
async function art(chan, url) {
|
|
|
|
|
var ext = path.extname(url)
|
|
|
|
|
if (ext === ".png") {
|
|
|
|
|
var filetype = "png"
|
|
|
|
|
} else if (ext === ".jpg") {
|
|
|
|
|
var filetype = "jpg"
|
2023-10-02 02:14:36 +00:00
|
|
|
|
} else if (ext === ".webp") {
|
|
|
|
|
var filetype = "webp"
|
2023-10-02 02:14:36 +00:00
|
|
|
|
} else if (ext === ".jpeg") {
|
|
|
|
|
var filetype = "jpeg"
|
2023-10-02 02:14:36 +00:00
|
|
|
|
} else {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
bot.say(chan, "Image must be PNG, JPG, JPEG, WEBP");
|
2023-10-02 02:14:36 +00:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
console.log("Starting Banter")
|
|
|
|
|
const spawn = require("child_process").spawn;
|
2023-10-02 02:14:36 +00:00
|
|
|
|
const pythonProcess = spawn('python3', ["lib/banter/banter.py", url, "-t", filetype])
|
2023-10-02 02:14:36 +00:00
|
|
|
|
pythonProcess.stdout.on('data', (data) => {
|
|
|
|
|
console.log(data.toString())
|
|
|
|
|
});
|
2023-10-02 02:14:36 +00:00
|
|
|
|
await timer(5000);
|
2023-10-02 02:14:36 +00:00
|
|
|
|
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') {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
console.log(err);
|
2023-10-02 02:14:36 +00:00
|
|
|
|
bot.say(chan, "Error")
|
|
|
|
|
} else {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
bot.say(chan, "Other Error")
|
2023-10-02 02:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-02 02:14:36 +00:00
|
|
|
|
async function godwords(chan, amt) {
|
|
|
|
|
if (amt > 100000) {
|
|
|
|
|
bot.say(chan, "no")
|
|
|
|
|
} else {
|
|
|
|
|
if (amt === undefined) {
|
|
|
|
|
var amt = 50
|
|
|
|
|
}
|
2023-10-02 02:14:36 +00:00
|
|
|
|
const worker = new Worker('./commands/godwords.js', {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
workerData: {
|
|
|
|
|
amt
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
worker.once('message', (string) => {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
console.log('Received string from worker, posting.');
|
2023-10-02 02:14:36 +00:00
|
|
|
|
bot.say(chan, string);
|
|
|
|
|
});
|
2023-10-02 02:14:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-02 02:14:35 +00:00
|
|
|
|
bot.addListener('message', function(nick, to, text, from) {
|
|
|
|
|
var args = text.split(' ');
|
|
|
|
|
if (args[0] === '$help') {
|
|
|
|
|
help(to);
|
|
|
|
|
} else if (args[0] === '$flood') {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
flood(to, args)
|
2023-10-02 02:14:35 +00:00
|
|
|
|
} else if (args[0] === '$sneed') {
|
|
|
|
|
sneed(to);
|
|
|
|
|
} else if (args[0] === '$ctcpflood') {
|
|
|
|
|
ctcp(args[1], args[2], args[3]);
|
|
|
|
|
} else if (args[0] === '$rspam') {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
rspam(to, args[1])
|
2023-10-02 02:14:35 +00:00
|
|
|
|
} else if (args[0] === '$uspam') {
|
2023-10-02 02:14:36 +00:00
|
|
|
|
uspam(to, args[1]);
|
2023-10-02 02:14:36 +00:00
|
|
|
|
} else if (args[0] === '$art') {
|
|
|
|
|
art(to, args[1]);
|
2023-10-02 02:14:37 +00:00
|
|
|
|
} else if (args[0] === 'fart') {
|
|
|
|
|
art(to, args[1]);
|
2023-10-02 02:14:36 +00:00
|
|
|
|
} else if (args[0] === '$godwords') {
|
|
|
|
|
godwords(to, args[1]);
|
2023-10-02 02:14:35 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-02 02:14:37 +00:00
|
|
|
|
bot.addListener('message', function(nick, to, text, from) {
|
|
|
|
|
if (text.startsWith(config.irc.prefix)) {
|
|
|
|
|
if (msgTimeout.has(to)) {
|
|
|
|
|
if (msgTimeoutMsg.has("yes")) {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
bot.say(to, errorMsg+" You are sending commands too quickly")
|
|
|
|
|
msgTimeoutMsg.add("yes");
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
msgTimeoutMsg.delete("yes");
|
|
|
|
|
}, config.floodprotect.command_listen_timeout)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
var args = text.split(' ');
|
|
|
|
|
var command = args[0].toLowerCase()
|
|
|
|
|
if (args[0] === '$help') {
|
|
|
|
|
help(to);
|
|
|
|
|
} else if (command === config.irc.prefix+'flood') {
|
|
|
|
|
flood(to, args)
|
|
|
|
|
} else if (command === config.irc.prefix+'sneed') {
|
|
|
|
|
sneed(to);
|
|
|
|
|
} else if (command === config.irc.prefix+'ctcpflood') {
|
|
|
|
|
ctcp(args[1], args[2], args[3]);
|
|
|
|
|
} else if (command === config.irc.prefix+'rspam') {
|
|
|
|
|
rspam(to, args[1])
|
|
|
|
|
} else if (command === config.irc.prefix+'uspam') {
|
|
|
|
|
uspam(to, args[1]);
|
|
|
|
|
} else if (command === config.irc.prefix+'art') {
|
|
|
|
|
art(to, args[1]);
|
|
|
|
|
} else if (command === config.irc.prefix+'fart') {
|
|
|
|
|
art(to, args[1]);
|
|
|
|
|
} else if (command === config.irc.prefix+'godwords') {
|
|
|
|
|
godwords(to, args[1]);
|
|
|
|
|
}
|
|
|
|
|
msgTimeout.add(to);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
msgTimeout.delete(to);
|
|
|
|
|
}, config.floodprotect.command_listen_timeout)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
2023-10-02 02:14:35 +00:00
|
|
|
|
bot.addListener('error', function(message) {
|
|
|
|
|
console.log('error: ', message);
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-02 02:14:36 +00:00
|
|
|
|
console.log('Starting Fascinus');
|