vm2 instead of sandbox, remove googlesearch
This commit is contained in:
parent
56a5bf8ba3
commit
6f09ed9cf8
|
@ -1,35 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
let crypto = require("crypto");
|
let crypto = require("crypto");
|
||||||
let Sandbox = require("sandbox");
|
let VM = require('vm2').VM;
|
||||||
let google = require("google");
|
|
||||||
google.resultsPerPage = 1;
|
|
||||||
google.lang = "de";
|
|
||||||
google.tld = "de";
|
|
||||||
google.nextText = "Weiter";
|
|
||||||
|
|
||||||
const googleSearch = function (client, o) {
|
|
||||||
google(o.args, function (err, res) {
|
|
||||||
if (err) return;
|
|
||||||
|
|
||||||
const links = res.links;
|
|
||||||
|
|
||||||
if (links.length === 0) {
|
|
||||||
client.say(o.to, o.from + ": could not find anything D:");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
client.say(o.to, o.from + ": " + links[0].link + " " + links[0].title + " - " + links[0].description.replace(/(\r\n|\r|\n|\t)/g, " "));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
let s = new Sandbox({
|
|
||||||
timeout: 1000
|
|
||||||
});
|
|
||||||
|
|
||||||
setInterval(x=>{
|
|
||||||
s.run("true", x=>{});
|
|
||||||
}, 10000);
|
|
||||||
|
|
||||||
let sbhead = "\"use strict\";const mett=9000,belst=Math.random()*mett|0;";
|
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("");
|
||||||
|
@ -56,25 +28,25 @@ p.run = function (o) {
|
||||||
if (level === null || level === undefined) level = -1;
|
if (level === null || level === undefined) level = -1;
|
||||||
switch(o.cmd) {
|
switch(o.cmd) {
|
||||||
case ".adhs":
|
case ".adhs":
|
||||||
let fuckyoujs = [...o.args.toLowerCase()];
|
let fuckyoujs = [...(o.args || o.from).toLowerCase()];
|
||||||
fuckyoujs = fuckyoujs.filter(c => /[a-z]/.test(c));
|
fuckyoujs = fuckyoujs.filter(c => /[a-z]/.test(c));
|
||||||
fuckyoujs = fuckyoujs.map((c, i) => {
|
fuckyoujs = fuckyoujs.map((c, i) => {
|
||||||
return alphanoise[((c.charCodeAt() -97) * (i+1) * 107) %26] /26;
|
return alphanoise[((c.charCodeAt() -97) * (i+1) * 107) %26] /26;
|
||||||
}).reduce((a,b)=>a+b) %1;
|
}).reduce((a,b)=>a+b) %1;
|
||||||
client.say(o.to, o.args + " has " + (fuckyoujs * 100).toFixed(2) + "% adhs");
|
client.say(o.to, (o.args || o.from) + " has " + (fuckyoujs * 100).toFixed(2) + "% adhs");
|
||||||
return true;
|
return true;
|
||||||
case ".level":
|
case ".level":
|
||||||
client.say(o.to, o.from + " your level: " + userLevelNames[level]);
|
client.say(o.to, o.from + " your level: " + userLevelNames[level]);
|
||||||
return true;
|
return true;
|
||||||
case ".reboot":
|
case ".reboot":
|
||||||
if (level < getLevel("admin") || o.args != "yourself") {
|
if (level < getLevel("admin")) {
|
||||||
client.say(o.to, o.from + " go kill yourself");
|
client.say(o.to, o.from + " go kill yourself");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
client.say(o.to, "kthx bai");
|
client.say(o.to, "kthx bai");
|
||||||
setTimeout(process.exit, 100);
|
setTimeout(process.exit, 100);
|
||||||
return true;
|
return true;
|
||||||
case ".reg":
|
/*case ".reg":
|
||||||
if (level < getLevel("admin")) {
|
if (level < getLevel("admin")) {
|
||||||
client.say(o.to, o.from + ": your level: " + userLevelNames[level] + ", needed level: admin");
|
client.say(o.to, o.from + ": your level: " + userLevelNames[level] + ", needed level: admin");
|
||||||
return true;
|
return true;
|
||||||
|
@ -87,7 +59,11 @@ p.run = function (o) {
|
||||||
exec("/bin/bash /home/sirx/web/w0bm.com/resources/views/"+o.args+".sh", (err, sout, serr)=>{
|
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"));
|
client.say(o.to, "Registration successfully " + (o.args == "open" ? "opened you can now register your account at https://w0bm.com/register" : "closed"));
|
||||||
});
|
});
|
||||||
break;
|
break;*/
|
||||||
|
|
||||||
|
case ".reg":
|
||||||
|
client.say(o.to, "User limit reached");
|
||||||
|
return true;
|
||||||
case ".status":
|
case ".status":
|
||||||
/*if (level < getLevel("admin")) {
|
/*if (level < getLevel("admin")) {
|
||||||
client.say(o.to, o.from + ": dein level: " + userLevelNames[level] + ", benötigtes level: admin");
|
client.say(o.to, o.from + ": dein level: " + userLevelNames[level] + ", benötigtes level: admin");
|
||||||
|
@ -96,11 +72,11 @@ p.run = function (o) {
|
||||||
|
|
||||||
db.getConnection((err, con) => {
|
db.getConnection((err, con) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
client.say(o.to, "sorry.. datenbank is kapott D: BKA belst gz");
|
client.say(o.to, "sorry.. datenbank is kapott D: nixc jkhsjdhjs Flummi");
|
||||||
con.release();
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
con.query("select disabled, deleted_at, banend, banreason, verified from users where username like ?", o.args, (err, rows, fields) => {
|
con.query("select disabled, deleted_at, banend, banreason, verified from users where username like ?", o.args || o.from, (err, rows, fields) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
client.say(o.to, "ich bin zu doof zum coden.. hier hat sich ein fehler eingeschlichen D:");
|
client.say(o.to, "ich bin zu doof zum coden.. hier hat sich ein fehler eingeschlichen D:");
|
||||||
con.release();
|
con.release();
|
||||||
|
@ -124,7 +100,7 @@ p.run = function (o) {
|
||||||
if (row.banend) stati.push("gebannt mit grund: " + row.banreason + ", bis: " + row.banend);
|
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);
|
if (row.deleted_at) stati.push("gelöscht seit: " + row.deleted_at);
|
||||||
|
|
||||||
client.say(o.to, o.args + " ist: " + stati.join(", "));
|
client.say(o.to, (o.args || o.from) + " ist: " + stati.join(", "));
|
||||||
/*var vid = rows[0];
|
/*var vid = rows[0];
|
||||||
if (!vid.id) {
|
if (!vid.id) {
|
||||||
client.say(to, from + ": konnte kein video finden D:");
|
client.say(to, from + ": konnte kein video finden D:");
|
||||||
|
@ -163,15 +139,16 @@ p.run = function (o) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case "js":
|
case "js":
|
||||||
/*if (level < getLevel("voiced")) {
|
let s = new VM({timeout: 1000, sandbox: {}});
|
||||||
client.say(o.to, o.from + ": dein level: " + userLevelNames[level] + ", benötigtes level: voiced");
|
let text;
|
||||||
return true;
|
try {
|
||||||
}*/
|
const out = s.run(sbhead + o.args + "+\"\"");
|
||||||
s.run(sbhead + o.args + "+\"\"", function (out) {
|
text = out.replace(/[\r\n\t]/g, " ");
|
||||||
let con = out.console.length > 0 ? " and printed to console: " + out.console : "";
|
}
|
||||||
let text = (out.result + con).replace(/[\r\n\t]/g, " ");
|
catch(e) {
|
||||||
|
text = e.toString();
|
||||||
|
}
|
||||||
client.say(o.to, o.from + " it returned: " + (text.length > 400 ? "fuck you" : text));
|
client.say(o.to, o.from + " it returned: " + (text.length > 400 ? "fuck you" : text));
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case "throw":
|
case "throw":
|
||||||
|
@ -191,30 +168,6 @@ p.run = function (o) {
|
||||||
client.say(o.to, o.from + ": i'd choose: " + choice);
|
client.say(o.to, o.from + ": i'd choose: " + choice);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case ".mdn":
|
|
||||||
case "mdn":
|
|
||||||
o.args += " site:developer.mozilla.org";
|
|
||||||
googleSearch(client, o);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case "hoogle":
|
|
||||||
case ".hs":
|
|
||||||
case "hs":
|
|
||||||
case "hss":
|
|
||||||
o.args += " site:www.haskell.org/hoogle/";
|
|
||||||
googleSearch(client, o);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case ".die":
|
|
||||||
o.args += " site:die.net";
|
|
||||||
googleSearch(client, o);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//case "google":
|
|
||||||
case ".google":
|
|
||||||
googleSearch(client, o);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case "b2o":
|
case "b2o":
|
||||||
case "b2d":
|
case "b2d":
|
||||||
case "b2h":
|
case "b2h":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user