2016-11-18 10:58:50 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
let crypto = require("crypto");
|
2023-07-18 13:00:11 +00:00
|
|
|
let VM = require('vm2').VM;
|
2016-11-18 10:58:50 +00:00
|
|
|
|
|
|
|
let sbhead = "\"use strict\";const mett=9000,belst=Math.random()*mett|0;";
|
2016-12-01 10:47:41 +00:00
|
|
|
sbhead += Object.getOwnPropertyNames(Math).map(function(v){return "const " + v + "=Math." + v + ";"}).join("");
|
2016-11-18 10:58:50 +00:00
|
|
|
|
|
|
|
let handleChatCommands = function (irc, db) {
|
|
|
|
this.irc = irc;
|
|
|
|
this.db = db;
|
|
|
|
};
|
|
|
|
|
|
|
|
let p = handleChatCommands.prototype;
|
|
|
|
|
|
|
|
const userLevels = ["","+","%","@","&","~"];
|
|
|
|
const userLevelNames = ["user", "voiced", "halfop", "op", "admin", "owner"];
|
|
|
|
const getLevel = name => userLevelNames.indexOf(name);
|
|
|
|
const exec = require("child_process").exec;
|
2018-04-25 11:34:25 +00:00
|
|
|
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];
|
2016-11-18 10:58:50 +00:00
|
|
|
|
|
|
|
p.run = function (o) {
|
|
|
|
let client = this.irc.client;
|
|
|
|
let db = this.db;
|
|
|
|
//let level = client.chans[o.to] ? client.chans[o.to].users[o.from] : undefined;
|
|
|
|
let level = client.chans["#w0bm"] ? client.chans["#w0bm"].users[o.from] : undefined;
|
2016-12-04 21:08:37 +00:00
|
|
|
level = level !== undefined ? level.split("").map(x=>userLevels.indexOf(x)).sort().pop() : -1;
|
|
|
|
if (level === null || level === undefined) level = -1;
|
2016-11-18 10:58:50 +00:00
|
|
|
switch(o.cmd) {
|
2018-04-25 11:34:25 +00:00
|
|
|
case ".adhs":
|
2023-07-18 13:00:11 +00:00
|
|
|
let fuckyoujs = [...(o.args || o.from).toLowerCase()];
|
2018-05-04 13:32:47 +00:00
|
|
|
fuckyoujs = fuckyoujs.filter(c => /[a-z]/.test(c));
|
|
|
|
fuckyoujs = fuckyoujs.map((c, i) => {
|
2018-04-25 11:37:13 +00:00
|
|
|
return alphanoise[((c.charCodeAt() -97) * (i+1) * 107) %26] /26;
|
2018-04-25 11:34:25 +00:00
|
|
|
}).reduce((a,b)=>a+b) %1;
|
2023-07-18 13:00:11 +00:00
|
|
|
client.say(o.to, (o.args || o.from) + " has " + (fuckyoujs * 100).toFixed(2) + "% adhs");
|
2018-04-25 10:57:22 +00:00
|
|
|
return true;
|
2016-12-01 10:47:41 +00:00
|
|
|
case ".level":
|
2019-04-04 11:30:14 +00:00
|
|
|
client.say(o.to, o.from + " your level: " + userLevelNames[level]);
|
2016-12-01 10:47:41 +00:00
|
|
|
return true;
|
|
|
|
case ".reboot":
|
2023-07-18 13:00:11 +00:00
|
|
|
if (level < getLevel("admin")) {
|
2016-12-01 10:47:41 +00:00
|
|
|
client.say(o.to, o.from + " go kill yourself");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
client.say(o.to, "kthx bai");
|
|
|
|
setTimeout(process.exit, 100);
|
|
|
|
return true;
|
2023-07-18 13:00:11 +00:00
|
|
|
/*case ".reg":
|
2016-11-18 10:58:50 +00:00
|
|
|
if (level < getLevel("admin")) {
|
2019-04-04 11:30:14 +00:00
|
|
|
client.say(o.to, o.from + ": your level: " + userLevelNames[level] + ", needed level: admin");
|
2016-11-18 10:58:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!~["open", "close"].indexOf(o.args)) {
|
|
|
|
client.say(o.to, "momentane befehle: open und close");
|
|
|
|
return true;
|
|
|
|
}
|
2019-04-04 11:30:14 +00:00
|
|
|
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"));
|
2016-11-18 10:58:50 +00:00
|
|
|
});
|
2023-07-18 13:00:11 +00:00
|
|
|
break;*/
|
|
|
|
|
|
|
|
case ".reg":
|
|
|
|
client.say(o.to, "User limit reached");
|
|
|
|
return true;
|
2016-11-18 10:58:50 +00:00
|
|
|
case ".status":
|
|
|
|
/*if (level < getLevel("admin")) {
|
|
|
|
client.say(o.to, o.from + ": dein level: " + userLevelNames[level] + ", benötigtes level: admin");
|
|
|
|
return true;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
db.getConnection((err, con) => {
|
|
|
|
if (err) {
|
2023-07-18 13:00:11 +00:00
|
|
|
client.say(o.to, "sorry.. datenbank is kapott D: nixc jkhsjdhjs Flummi");
|
|
|
|
console.error(err);
|
2016-11-18 10:58:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-07-18 13:00:11 +00:00
|
|
|
con.query("select disabled, deleted_at, banend, banreason, verified from users where username like ?", o.args || o.from, (err, rows, fields) => {
|
2016-11-18 10:58:50 +00:00
|
|
|
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);
|
|
|
|
|
2023-07-18 13:00:11 +00:00
|
|
|
client.say(o.to, (o.args || o.from) + " ist: " + stati.join(", "));
|
2016-11-18 10:58:50 +00:00
|
|
|
/*var vid = rows[0];
|
|
|
|
if (!vid.id) {
|
|
|
|
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");
|
|
|
|
["interpret", "songtitle", "category", "username", "comments"].forEach((v, i) => {
|
|
|
|
if (vid[v]) {
|
|
|
|
txt.push(
|
|
|
|
["Interpret", "Titel", "Kategorie", "Uploader", "Kommentare"][i] + ": "
|
|
|
|
+"\x02" + vid[v] + "\x0f");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
client.say(to, txt.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;
|
|
|
|
|
|
|
|
case "js":
|
2023-07-18 13:00:11 +00:00
|
|
|
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));
|
2016-11-18 10:58:50 +00:00
|
|
|
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 "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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|