retab code with 4 spaces

This commit is contained in:
Flummi 2023-07-20 12:49:05 +00:00
parent 2c3b284e37
commit a18dae5fd2
3 changed files with 303 additions and 303 deletions

View File

@ -1,14 +1,14 @@
{
"servers": {
"asd": {
"host": "domain.tld",
"port": 6667,
"secure": false,
"srvPassword": "example",
"nick": "bert",
"userName": "foo",
"realName": "bar"
}
}
"servers": {
"asd": {
"host": "domain.tld",
"port": 6667,
"secure": false,
"srvPassword": "example",
"nick": "bert",
"userName": "foo",
"realName": "bar"
}
}
}

View File

@ -4,11 +4,11 @@ let crypto = require("crypto");
let VM = require('vm2').VM;
let sbhead = "\"use strict\";const mett=9000,belst=Math.random()*mett|0;";
sbhead += Object.getOwnPropertyNames(Math).map(function(v){return "const " + v + "=Math." + v + ";"}).join("");
sbhead += Object.getOwnPropertyNames(Math).map(function(v){return "const " + v + "=Math." + v + ";"}).join("");
let handleChatCommands = function (irc, db) {
this.irc = irc;
this.db = db;
this.irc = irc;
this.db = db;
};
let p = handleChatCommands.prototype;
@ -20,153 +20,153 @@ const exec = require("child_process").exec;
const alphanoise = [8,20,10,14,12,11,26,16,4,21,22,13,24,6,5,15,2,23,7,19,18,25,9,3,17,1];
p.run = function (o) {
let client = this.irc.client;
let db = this.db;
let level = client.chans["#w0bm"] ? client.chans["#w0bm"].users[o.from] : undefined;
level = level !== undefined ? level.split("").map(x=>userLevels.indexOf(x)).sort().pop() : -1;
if (level === null || level === undefined) level = -1;
switch(o.cmd) {
case ".adhs":
let fuckyoujs = [...(o.args || o.from).toLowerCase()];
fuckyoujs = fuckyoujs.filter(c => /[a-z]/.test(c));
fuckyoujs = fuckyoujs.map((c, i) => {
return alphanoise[((c.charCodeAt() -97) * (i+1) * 107) %26] /26;
}).reduce((a,b)=>a+b) %1;
client.say(o.to, (o.args || o.from) + " has " + (fuckyoujs * 100).toFixed(2) + "% adhs");
return true;
case ".level":
client.say(o.to, o.from + " your level: " + userLevelNames[level]);
return true;
case ".reboot":
if (level < getLevel("admin")) {
client.say(o.to, o.from + " go kill yourself");
break;
}
client.say(o.to, "kthx bai");
setTimeout(process.exit, 100);
return true;
/*case ".reg":
if (level < getLevel("admin")) {
client.say(o.to, o.from + ": your level: " + userLevelNames[level] + ", needed level: admin");
return true;
}
if (!~["open", "close"].indexOf(o.args)) {
client.say(o.to, "momentane befehle: open und close");
return true;
}
client.say(o.to, "Your word is my command");
exec("/bin/bash /home/sirx/web/w0bm.com/resources/views/"+o.args+".sh", (err, sout, serr)=>{
client.say(o.to, "Registration successfully " + (o.args == "open" ? "opened you can now register your account at https://w0bm.com/register" : "closed"));
});
break;*/
let client = this.irc.client;
let db = this.db;
let level = client.chans["#w0bm"] ? client.chans["#w0bm"].users[o.from] : undefined;
level = level !== undefined ? level.split("").map(x=>userLevels.indexOf(x)).sort().pop() : -1;
if (level === null || level === undefined) level = -1;
switch(o.cmd) {
case ".adhs":
let fuckyoujs = [...(o.args || o.from).toLowerCase()];
fuckyoujs = fuckyoujs.filter(c => /[a-z]/.test(c));
fuckyoujs = fuckyoujs.map((c, i) => {
return alphanoise[((c.charCodeAt() -97) * (i+1) * 107) %26] /26;
}).reduce((a,b)=>a+b) %1;
client.say(o.to, (o.args || o.from) + " has " + (fuckyoujs * 100).toFixed(2) + "% adhs");
return true;
case ".level":
client.say(o.to, o.from + " your level: " + userLevelNames[level]);
return true;
case ".reboot":
if (level < getLevel("admin")) {
client.say(o.to, o.from + " go kill yourself");
break;
}
client.say(o.to, "kthx bai");
setTimeout(process.exit, 100);
return true;
/*case ".reg":
if (level < getLevel("admin")) {
client.say(o.to, o.from + ": your level: " + userLevelNames[level] + ", needed level: admin");
return true;
}
if (!~["open", "close"].indexOf(o.args)) {
client.say(o.to, "momentane befehle: open und close");
return true;
}
client.say(o.to, "Your word is my command");
exec("/bin/bash /home/sirx/web/w0bm.com/resources/views/"+o.args+".sh", (err, sout, serr)=>{
client.say(o.to, "Registration successfully " + (o.args == "open" ? "opened you can now register your account at https://w0bm.com/register" : "closed"));
});
break;*/
case ".reg":
client.say(o.to, "User limit reached");
return true;
case ".status":
db.getConnection((err, con) => {
if (err) {
client.say(o.to, "sorry.. datenbank is kapott D: nixc jkhsjdhjs Flummi");
console.error(err);
return;
}
con.query("select disabled, deleted_at, banend, banreason, verified from users where username like ?", o.args || o.from, (err, rows, fields) => {
if (err) {
client.say(o.to, "ich bin zu doof zum coden.. hier hat sich ein fehler eingeschlichen D:");
con.release();
return;
}
if (rows.length == 0) {
client.say(o.to, "konnte keinen benutzer mit dem namen finden D:");
con.release();
return;
}
if (rows.length > 1) {
client.say(o.to, "fick dich. hör auf wildcards zu nutzen… oder… wir haben ein datenbank problem…");
con.release();
return;
}
const row = rows[0];
const stati = [];
if (row.disabled) stati.push("deaktiviert");
if (!row.disabled) stati.push("aktiviert");
if (!row.verified) stati.push("nicht verifiziert");
if (row.banend) stati.push("gebannt mit grund: " + row.banreason + ", bis: " + row.banend);
if (row.deleted_at) stati.push("gelöscht seit: " + row.deleted_at);
case ".reg":
client.say(o.to, "User limit reached");
return true;
case ".status":
db.getConnection((err, con) => {
if (err) {
client.say(o.to, "sorry.. datenbank is kapott D: nixc jkhsjdhjs Flummi");
console.error(err);
return;
}
con.query("select disabled, deleted_at, banend, banreason, verified from users where username like ?", o.args || o.from, (err, rows, fields) => {
if (err) {
client.say(o.to, "ich bin zu doof zum coden.. hier hat sich ein fehler eingeschlichen D:");
con.release();
return;
}
if (rows.length == 0) {
client.say(o.to, "konnte keinen benutzer mit dem namen finden D:");
con.release();
return;
}
if (rows.length > 1) {
client.say(o.to, "fick dich. hör auf wildcards zu nutzen… oder… wir haben ein datenbank problem…");
con.release();
return;
}
const row = rows[0];
const stati = [];
if (row.disabled) stati.push("deaktiviert");
if (!row.disabled) stati.push("aktiviert");
if (!row.verified) stati.push("nicht verifiziert");
if (row.banend) stati.push("gebannt mit grund: " + row.banreason + ", bis: " + row.banend);
if (row.deleted_at) stati.push("gelöscht seit: " + row.deleted_at);
client.say(o.to, (o.args || o.from) + " ist: " + stati.join(", "));
con.release();
});
});
client.say(o.to, (o.args || o.from) + " ist: " + stati.join(", "));
con.release();
});
});
return true;
case "md5sum":
case "sha1sum":
case "sha256sum":
case "sha512sum":
o.cmd = o.cmd.substr(0, o.cmd.length -3);
case "md5":
case "sha1":
case "sha256":
case "sha512":
let crypt = crypto.createHash(o.cmd);
crypt.update(o.args);
client.say(o.to, "teh " + o.cmd + " sum iz: " + crypt.digest("hex"));
return true;
return true;
case "md5sum":
case "sha1sum":
case "sha256sum":
case "sha512sum":
o.cmd = o.cmd.substr(0, o.cmd.length -3);
case "md5":
case "sha1":
case "sha256":
case "sha512":
let crypt = crypto.createHash(o.cmd);
crypt.update(o.args);
client.say(o.to, "teh " + o.cmd + " sum iz: " + crypt.digest("hex"));
return true;
case "js":
let s = new VM({timeout: 1000, sandbox: {}});
let text;
try {
const out = s.run(sbhead + o.args + "+\"\"");
text = out.replace(/[\r\n\t]/g, " ");
}
catch(e) {
text = e.toString();
}
client.say(o.to, o.from + " it returned: " + (text.length > 400 ? "fuck you" : text));
return true;
case "js":
let s = new VM({timeout: 1000, sandbox: {}});
let text;
try {
const out = s.run(sbhead + o.args + "+\"\"");
text = out.replace(/[\r\n\t]/g, " ");
}
catch(e) {
text = e.toString();
}
client.say(o.to, o.from + " it returned: " + (text.length > 400 ? "fuck you" : text));
return true;
case "throw":
if (o.args != "a dice") break;
client.say(o.to, o.from + ": the magic dice shows " + ((Math.random()*6|0)+1) + " eyes.");
return true;
case "throw":
if (o.args != "a dice") break;
client.say(o.to, o.from + ": the magic dice shows " + ((Math.random()*6|0)+1) + " eyes.");
return true;
case ".choose":
case "choose:":
case "choice:":
let choices = o.args.split(",").map((str)=>str.trim());
if (choices.length < 2) {
client.say(o.to, "fuck you " + o.from + "!");
return true;
};
let choice = ~choices.indexOf("w0bm") ? "w0bm of course!" : choices[Math.random() * choices.length | 0];
client.say(o.to, o.from + ": i'd choose: " + choice);
return true;
case ".choose":
case "choose:":
case "choice:":
let choices = o.args.split(",").map((str)=>str.trim());
if (choices.length < 2) {
client.say(o.to, "fuck you " + o.from + "!");
return true;
};
let choice = ~choices.indexOf("w0bm") ? "w0bm of course!" : choices[Math.random() * choices.length | 0];
client.say(o.to, o.from + ": i'd choose: " + choice);
return true;
case "b2o":
case "b2d":
case "b2h":
case "o2b":
case "o2d":
case "o2h":
case "d2b":
case "d2o":
case "d2h":
case "h2b":
case "h2o":
case "h2d":
if ({b:/[^01]/,o:/[^0-7]/,d:/[^\d]/,h:/[^\da-fA-F]/}[o.cmd[0]].test(o.args)) return false;
client.say(o.to, o.from + ": " + parseInt(o.args, {b:2,o:8,d:10,h:16}[o.cmd[0]]).toString({b:2,o:8,d:10,h:16}[o.cmd[2]]));
return true;
}
return false;
case "b2o":
case "b2d":
case "b2h":
case "o2b":
case "o2d":
case "o2h":
case "d2b":
case "d2o":
case "d2h":
case "h2b":
case "h2o":
case "h2d":
if ({b:/[^01]/,o:/[^0-7]/,d:/[^\d]/,h:/[^\da-fA-F]/}[o.cmd[0]].test(o.args)) return false;
client.say(o.to, o.from + ": " + parseInt(o.args, {b:2,o:8,d:10,h:16}[o.cmd[0]]).toString({b:2,o:8,d:10,h:16}[o.cmd[2]]));
return true;
}
return false;
};
module.exports = function (irc, db) {
let hcc = new handleChatCommands(irc, db);
return function (o) {
hcc.run(o);
}
let hcc = new handleChatCommands(irc, db);
return function (o) {
hcc.run(o);
}
};

302
index.js
View File

@ -8,37 +8,37 @@ const Mysql = require("mysql");
require('dotenv').config({path: '/srv/http/w0bm/.env'});
let db = Mysql.createPool({
socketPath: '/run/mysqld/mysqld.sock',
user: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
timezone: "utc"
socketPath: '/run/mysqld/mysqld.sock',
user: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
timezone: "utc"
});
let irc = {};
irc.client = new Irc.Client(config.servers.n0xy.host, config.servers.n0xy.nick, {
port: config.servers.n0xy.port,
secure: config.servers.n0xy.secure,
userName: config.servers.n0xy.userName,
realName: config.servers.n0xy.realName,
sasl: config.servers.n0xy.sasl,
debug: false,
debugRaw: false,
selfSigned: false,
autoConnect: true,
password: config.servers.n0xy.srvPassword,
channels: ["#w0bm", "#f0ck"]
port: config.servers.n0xy.port,
secure: config.servers.n0xy.secure,
userName: config.servers.n0xy.userName,
realName: config.servers.n0xy.realName,
sasl: config.servers.n0xy.sasl,
debug: false,
debugRaw: false,
selfSigned: false,
autoConnect: true,
password: config.servers.n0xy.srvPassword,
channels: ["#w0bm", "#f0ck"]
});
if (process.env.NODE_ENV != 'production') {
const repl = require("repl").start("> ");
repl.context.i = irc;
repl.context.c = irc.client;
repl.context.w = (msg) => irc.client.say("#w0bm", msg);
repl.context.s = (cmd, msg) => irc.client.send(cmd, msg);
const repl = require("repl").start("> ");
repl.context.i = irc;
repl.context.c = irc.client;
repl.context.w = (msg) => irc.client.say("#w0bm", msg);
repl.context.s = (cmd, msg) => irc.client.send(cmd, msg);
Object.defineProperty(repl.context, "q", {get:process.exit});
Object.defineProperty(repl.context, "q", {get:process.exit});
}
const handleChatCommands = require("./chatCommands")(irc, db);
@ -46,157 +46,157 @@ const handleChatCommands = require("./chatCommands")(irc, db);
const shiftRegex = /^(\.?\w+:?)(?:\s+(.+))?/;
const w0bmregex = /(?:\b(\w+)\.)?\bw0bm\.com\/(?:\w+\/){0,3}([^ '\/@`´]+\.(webm)|\d+)/i;
const capsmsg = [
"Captain capslock did not approve this!",
"CAPS",
"caps lock. unleash the mother fucking fury",
"DON'T YOU TYPE AT ME IN THAT TONE OF VOICE.",
"Suddenly, CAPS LOCK",
"OH, so you wanna argue? BRING IT. I got my CAPS LOCK ON",
"WELCOME TO THE INTERNET"
"Captain capslock did not approve this!",
"CAPS",
"caps lock. unleash the mother fucking fury",
"DON'T YOU TYPE AT ME IN THAT TONE OF VOICE.",
"Suddenly, CAPS LOCK",
"OH, so you wanna argue? BRING IT. I got my CAPS LOCK ON",
"WELCOME TO THE INTERNET"
];
irc.client.addListener("error", message => console.log("error: ", message));
irc.client.addListener("message", (from, to, message, raw) => {
const client = irc.client;
let pm;
if (pm = !/^#/.test(to)) {
if (client.opt.debug) console.log("setting to from:", to, "to:", from, "cause its a PM");
to = from;
}
if (client.opt.debug) console.log("from:", from, "to:", to, "message:", message);
if (shiftRegex.test(message)) {
let cmd = message.match(shiftRegex);
let args = (cmd[2] || "").trim();
cmd = cmd[1];
const client = irc.client;
let pm;
if (pm = !/^#/.test(to)) {
if (client.opt.debug) console.log("setting to from:", to, "to:", from, "cause its a PM");
to = from;
}
if (client.opt.debug) console.log("from:", from, "to:", to, "message:", message);
if (shiftRegex.test(message)) {
let cmd = message.match(shiftRegex);
let args = (cmd[2] || "").trim();
cmd = cmd[1];
if (handleChatCommands({
from: from,
to: to,
message: message,
cmd: cmd,
args: args
})) {
if (client.opt.debug)
console.log("cmd:", cmd, "arg:", args);
return;
}
}
if (handleChatCommands({
from: from,
to: to,
message: message,
cmd: cmd,
args: args
})) {
if (client.opt.debug)
console.log("cmd:", cmd, "arg:", args);
return;
}
}
/*if (/pr0gramm\.com/.test(message) && to == "#w0bm") {
client.say(to, pr0text[Math.random()*pr0text.length|0]);
return;
}*/
/*if (/pr0gramm\.com/.test(message) && to == "#w0bm") {
client.say(to, pr0text[Math.random()*pr0text.length|0]);
return;
}*/
if (message.toUpperCase() == message && message.trim().split("").filter(c=>/[A-Z]/.test(c)).length > 5) {
client.say(to, capsmsg[Math.random()*capsmsg.length|0]);
}
if (message.toUpperCase() == message && message.trim().split("").filter(c=>/[A-Z]/.test(c)).length > 5) {
client.say(to, capsmsg[Math.random()*capsmsg.length|0]);
}
if (w0bmregex.test(message)) {
var link = message.match(w0bmregex);
if (link) {
var id = link[2];
if (id.length > 20) {
client.say(to, "fuck you");
return;
}
var webm = link[3];
db.getConnection((err, con) => {
if (err) {
client.say(to, "sorry.. there seems to be a database problem right now D:");
con.release();
return;
}
con.query(
"select v.id, v.deleted_at, u.username, c.name as category, v.videotitle, v.interpret, v.songtitle, v.imgsource,"+
" (select 1 from taggable_taggables t where t.taggable_id = v.id and t.tag_id = 1) as sfw,"+
" (select count(cm.id) from comments cm where cm.video_id = v.id and cm.deleted_at is NULL) as comments"+
" from videos v, users u, categories c where v.user_id = u.id and v.category_id = c.id"+
" and " + (webm ? "v.file" : "v.id") + " = '" + id + "'", (err, rows, fields) => {
if (err) {
client.say(to, "sorry.. there seems to be an sql query problem D:");
client.say(to, "" + err);
con.release();
return;
}
var vid = rows[0];
if (!vid) {
client.say(to, from + ": konnte kein video finden D:");
con.release();
return;
}
var txt = [];
if (vid.deleted_at) txt.push("\x02gelöscht\x0f");
if (webm) txt.push("Link: \x02https://w0bm.com/" + vid.id + "\x0f");
txt.push(vid["sfw"] ? "\x039SFW\x0f" : "\x034NSFW\x0f");
["videotitle", "interpret", "songtitle", "category", "username", "comments"].forEach((v, i) => {
if (vid[v]) {
txt.push(
["Video Title", "Artist", "Song Title", "Category", "Uploader", "Comments"][i] + ": "
+"\x02" + vid[v] + "\x0f"
);
}
});
if (w0bmregex.test(message)) {
var link = message.match(w0bmregex);
if (link) {
var id = link[2];
if (id.length > 20) {
client.say(to, "fuck you");
return;
}
var webm = link[3];
db.getConnection((err, con) => {
if (err) {
client.say(to, "sorry.. there seems to be a database problem right now D:");
con.release();
return;
}
con.query(
"select v.id, v.deleted_at, u.username, c.name as category, v.videotitle, v.interpret, v.songtitle, v.imgsource,"+
" (select 1 from taggable_taggables t where t.taggable_id = v.id and t.tag_id = 1) as sfw,"+
" (select count(cm.id) from comments cm where cm.video_id = v.id and cm.deleted_at is NULL) as comments"+
" from videos v, users u, categories c where v.user_id = u.id and v.category_id = c.id"+
" and " + (webm ? "v.file" : "v.id") + " = '" + id + "'", (err, rows, fields) => {
if (err) {
client.say(to, "sorry.. there seems to be an sql query problem D:");
client.say(to, "" + err);
con.release();
return;
}
var vid = rows[0];
if (!vid) {
client.say(to, from + ": konnte kein video finden D:");
con.release();
return;
}
var txt = [];
if (vid.deleted_at) txt.push("\x02gelöscht\x0f");
if (webm) txt.push("Link: \x02https://w0bm.com/" + vid.id + "\x0f");
txt.push(vid["sfw"] ? "\x039SFW\x0f" : "\x034NSFW\x0f");
["videotitle", "interpret", "songtitle", "category", "username", "comments"].forEach((v, i) => {
if (vid[v]) {
txt.push(
["Video Title", "Artist", "Song Title", "Category", "Uploader", "Comments"][i] + ": "
+"\x02" + vid[v] + "\x0f"
);
}
});
client.say(to, txt.join(" | "));
con.release();
});
});
client.say(to, txt.join(" | "));
con.release();
});
});
return;
}
}
return;
}
}
if (haitext.includes(message.toLowerCase())) {
client.say(to, haitext[Math.random()*haitext.length|0] + " " + from + "!");
return;
}
if (haitext.includes(message.toLowerCase())) {
client.say(to, haitext[Math.random()*haitext.length|0] + " " + from + "!");
return;
}
if (/^!d$/.test(message)) {
client.say(to, from + ": the magic dice shows " + ((Math.random()*6|0)+1) + " eyes.");
}
if (/^!d$/.test(message)) {
client.say(to, from + ": the magic dice shows " + ((Math.random()*6|0)+1) + " eyes.");
}
if (/^a+[yi][yiou]*$/.test(message)) {
client.say(to, "ayy lmao");
return;
}
if (/^a+[yi][yiou]*$/.test(message)) {
client.say(to, "ayy lmao");
return;
}
if (/.+\?\?$/.test(message)) {
let ye = Math.random() * 2 | 0;
client.say(to, "[" + (ye?"x":" ") + "] ja [" + (ye?" ":"x") + "] nein | " + message);
return;
}
if (/.+\?\?$/.test(message)) {
let ye = Math.random() * 2 | 0;
client.say(to, "[" + (ye?"x":" ") + "] ja [" + (ye?" ":"x") + "] nein | " + message);
return;
}
if (~[".guuchan", ".vizon", ".lottery"].indexOf(message)) {
let values = new Array(29).fill().map((v,i)=>1+i);
let choices = new Array(6).fill().map(()=>values.splice(Math.random()*values.length|0,1)).sort((x,y)=>x-y).join(" ");
client.say(to, "/notice guuchan !bet " + choices);
return;
}
if (~[".guuchan", ".vizon", ".lottery"].indexOf(message)) {
let values = new Array(29).fill().map((v,i)=>1+i);
let choices = new Array(6).fill().map(()=>values.splice(Math.random()*values.length|0,1)).sort((x,y)=>x-y).join(" ");
client.say(to, "/notice guuchan !bet " + choices);
return;
}
});
const haitext = ["ohaio", "ohayou", "ohayo", "ohaiou", "ohai", "nabend", "morgen", "guten tag", "hallo", "hi", "hai", "hey", "moin", "hellau", "hello", "hallu", "yo", "servus", "tag", "tach", "alaaf", "alaf", "As-Salamu 'alaikum wa Rahmatullahi wa Barakatuhu"];
const pr0text = [
"pr0gramm.com existiert nicht!",
"endlich oc von deiner fotze?",
"Pfui Daibel",
"kommandozeile war vorher da",
"keiner von uns",
"Falsches Grau",
"das reicht uns nicht",
"Zapalot nochmal!",
"meinten sie reddit, 9gag oder fagbook?",
"lustig weil pr0gramm",
"lustig weil fett",
"marina die huuure",
"har har har kefer",
"Ach du scheiße. Da drückste Minus.",
"0815 wie fick",
"stumpf ist trumpf",
"f man weiß ja nie",
"lass das nicht die repost polizei sehen!"
"pr0gramm.com existiert nicht!",
"endlich oc von deiner fotze?",
"Pfui Daibel",
"kommandozeile war vorher da",
"keiner von uns",
"Falsches Grau",
"das reicht uns nicht",
"Zapalot nochmal!",
"meinten sie reddit, 9gag oder fagbook?",
"lustig weil pr0gramm",
"lustig weil fett",
"marina die huuure",
"har har har kefer",
"Ach du scheiße. Da drückste Minus.",
"0815 wie fick",
"stumpf ist trumpf",
"f man weiß ja nie",
"lass das nicht die repost polizei sehen!"
];