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;";
|
2023-07-20 12:49:05 +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) {
|
2023-07-20 12:49:05 +00:00
|
|
|
this.irc = irc;
|
|
|
|
this.db = db;
|
2016-11-18 10:58:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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) {
|
2023-07-20 12:49:05 +00:00
|
|
|
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;*/
|
2023-07-18 13:00:11 +00:00
|
|
|
|
2023-07-20 12:49:05 +00:00
|
|
|
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);
|
2016-11-18 10:58:50 +00:00
|
|
|
|
2023-07-20 12:49:05 +00:00
|
|
|
client.say(o.to, (o.args || o.from) + " ist: " + stati.join(", "));
|
|
|
|
con.release();
|
|
|
|
});
|
|
|
|
});
|
2016-11-18 10:58:50 +00:00
|
|
|
|
2023-07-20 12:49:05 +00:00
|
|
|
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;
|
2016-11-18 10:58:50 +00:00
|
|
|
|
2023-07-20 12:49:05 +00:00
|
|
|
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;
|
2016-11-18 10:58:50 +00:00
|
|
|
|
2023-07-20 12:49:05 +00:00
|
|
|
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;
|
2016-11-18 10:58:50 +00:00
|
|
|
|
2023-07-20 12:49:05 +00:00
|
|
|
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;
|
2016-11-18 10:58:50 +00:00
|
|
|
|
2023-07-20 12:49:05 +00:00
|
|
|
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;
|
2016-11-18 10:58:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = function (irc, db) {
|
2023-07-20 12:49:05 +00:00
|
|
|
let hcc = new handleChatCommands(irc, db);
|
|
|
|
return function (o) {
|
|
|
|
hcc.run(o);
|
|
|
|
}
|
2016-11-18 10:58:50 +00:00
|
|
|
};
|
|
|
|
|