This commit is contained in:
Flummi 2017-11-22 02:43:57 +01:00
parent e92dbbbcb0
commit 0906a4a0b4
6 changed files with 493 additions and 171 deletions

View File

@ -16,7 +16,7 @@ module.exports = bot => {
const releases = JSON.parse(content).releases;
const out = [];
for (let entry in releases)
out.push(`[b]${releases[entry].version}[/b] (${releases[entry].moniker}${releases[entry].iseol ? `, EOL` : ""})`);
out.push(`[b]${releases[entry].version}[/b] (${releases[entry].moniker}${releases[entry].iseol ? `, [i]EOL[/i]` : ""})`);
e.reply(out.join(", "));
});
});

View File

@ -1,13 +0,0 @@
function bfgen(text) {
let out = "+".repeat(10) + "[";
let repeat = 0;
for (let i = 0; i < text.length; i++)
repeat = text.charCodeAt(i) - text.charCodeAt(i) % 10;
out += repeat > 10 ? '>' + "+".repeat(repeat / 10) : null;
out += "<".repeat(out.split(">").length - 1) + "-]";
for (let i = 0; i < text.length; i++)
out += ">" + "+".repeat(text.charCodeAt(i) % 10) + ".";
return out;
}
export default { bfgen };

View File

@ -0,0 +1,93 @@
const request = require("request");
const maxoutput = 400;
const hsimports = [
"Control.Applicative", "Control.Arrow", "Control.Monad",
"Control.Monad.Zip", "Data.Bits", "Data.Bool", "Data.Char",
"Data.Complex", "Data.Data", "Data.Eq", "Data.Fixed",
"Data.Foldable", "Data.Function", "Data.Functor",
"Data.Int", "Data.List", "Data.Maybe", "Data.Monoid", "Data.Map",
"Data.Ord", "Data.Set", "Data.String", "Data.Tuple", "Data.Word"
].map(imp => { return `import qualified ${imp}`; }).join("\r\n");
function sandbox(lang, code) {
const langs = {
cpp: {
"LanguageChoice": "7",
"Program": "#include <iostream>\r\nint main() { " + code + "}",
"Input": "",
"CompilerArgs": "-Wall -std=c++14 -O2 -o a.out source_file.cpp"
},
hs: {
"LanguageChoice": "11",
"Program": `${hsimports}\r\nmain = print(${code})`,
"Input": "",
"CompilerArgs": "-XUnicodeSyntax -XPartialTypeSignatures -o a.out source_file.hs"
},
py: {
"LanguageChoice": "24",
"Program": "print(" + code + ")",
"Input": "",
"CompilerArgs": "-o a.out source_file.hs"
},
bf: {
"LanguageChoice": "44",
"Program": code,
"Input": "",
"CompilerArgs": ""
},
php: {
"LanguageChoice": "8",
"Program": "<?php\r\n" + code + "\r\n?>",
"Input": "",
"CompilerArgs": ""
},
lua: {
"LanguageChoice": "14",
"Program": code,
"Input": "",
"CompilerArgs": ""
}
};
return new Promise((resolve, reject) => {
const options = {
url: "http://rextester.com/rundotnet/api",
method: "POST",
body: langs[lang],
json: true
};
request(options, (err, res, body) => {
if (err)
return reject("Error!");
if (body.Errors) {
if (body.Errors.length > maxoutput)
return reject(`holy fuck, Error wäre viel zu lang! (${body.Errors.length} Zeichen :DDDDDD)`)
return reject(body.Errors);
}
if (body.Result === null)
return reject("Keine Ausgabe :(");
if (body.Result.length > maxoutput)
return reject(`holy fuck, Ausgabe wäre viel zu lang! (${body.Result.length} Zeichen :DDDDDD)`);
if (body.Result.length === 0)
return reject("lol keine Ausgabe");
resolve(body.Result);
});
});
}
function bfgen(text) {
let out = "+".repeat(10) + "[";
let repeat = 0;
for (let i = 0; i < text.length; i++)
repeat = text.charCodeAt(i) - text.charCodeAt(i) % 10;
out += repeat > 10 ? '>' + "+".repeat(repeat / 10) : null;
out += "<".repeat(out.split(">").length - 1) + "-]";
for (let i = 0; i < text.length; i++)
out += ">" + "+".repeat(text.charCodeAt(i) % 10) + ".";
return out;
}
export { maxoutput, sandbox, bfgen };

View File

@ -1,10 +1,8 @@
import { bfgen } from "./lib/brainfuck.js";
import { maxoutput, sandbox, bfgen } from "./lib/sandbox.js";
const vm = require("vm")
, request = require("request");
const maxoutput = 400;
module.exports = bot => {
bot._trigger.set("sandbox_js", {
call: /^\!js (.*)/i,
@ -32,71 +30,6 @@ module.exports = bot => {
}
});
function sandbox(lang, code) {
const langs = {
cpp: {
"LanguageChoice": "7",
"Program": "#include <iostream>\r\nint main() { " + code + "}",
"Input": "",
"CompilerArgs": "-Wall -std=c++14 -O2 -o a.out source_file.cpp"
},
hs: {
"LanguageChoice": "11",
"Program": "{-# LANGUAGE UnicodeSyntax #-}\r\nmain = " + code,
"Input": "",
"CompilerArgs": "-o a.out source_file.hs"
},
py: {
"LanguageChoice": "24",
"Program": "print(" + code + ")",
"Input": "",
"CompilerArgs": "-o a.out source_file.hs"
},
bf: {
"LanguageChoice": "44",
"Program": code,
"Input": "",
"CompilerArgs": ""
},
php: {
"LanguageChoice": "8",
"Program": "<?php\r\n" + code + "\r\n?>",
"Input": "",
"CompilerArgs": ""
},
lua: {
"LanguageChoice": "14",
"Program": code,
"Input": "",
"CompilerArgs": ""
}
};
return new Promise((resolve, reject) => {
const options = {
url: "http://rextester.com/rundotnet/api",
method: "POST",
body: langs[lang],
json: true
};
request(options, (err, res, body) => {
if(err)
return reject("Error!");
if(body.Errors) {
if(body.Errors.length > maxoutput)
return reject(`holy fuck, Error wäre viel zu lang! (${body.Errors.length} Zeichen :DDDDDD)`)
return reject(body.Errors);
}
if(body.Result === null)
return reject("Keine Ausgabe :(");
if(body.Result.length > maxoutput)
return reject(`holy fuck, Ausgabe wäre viel zu lang! (${body.Result.length} Zeichen :DDDDDD)`);
resolve(body.Result);
});
});
}
bot._trigger.set("sandbox", {
call: /^\!(hs|py|cpp|bf|php|lua) .*/i,
level: 100,

View File

@ -4,13 +4,8 @@ const data = {
yiff: [],
kill_templates: [],
kill_parts: {},
abschieben: [],
kaffee: [],
quotes_firecooler: [],
quotes_kinski: [],
quotes_stoll: [],
quotes_boll: [],
genders: []
genders: [],
woahs: []
};
Object.keys(data).forEach(cur => {
@ -55,7 +50,7 @@ module.exports = bot => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(data.kill_templates[~~(Math.random() * data.kill_templates.length)]
.replace("{user}", `[b]${args[0]}[/b]`)
.replace("{limbs}", data.kill_parts.limbs[~~(Math.random() * data.kill_parts.limbs.length)])
@ -87,32 +82,6 @@ module.exports = bot => {
}
});
bot._trigger.set("abschieben", {
call: /^(.|\/)abschieben/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`schiebt [b]${args[0]}[/b] ${data.abschieben[~~(Math.random() * data.abschieben.length)]} ab.`);
}
});
bot._trigger.set("butterkaese", {
call: /^(.|\/)butterkäse/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`drischt mit einem großen Stück Butterkäse auf [b]${args[0]}[/b] ein.`);
}
});
bot._trigger.set("bier", {
call: /^(.|\/)bier/i,
level: 0,
@ -126,44 +95,6 @@ module.exports = bot => {
}
});
bot._trigger.set("notschlachten", {
call: /^(.|\/)notschlachten/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`notschlachtet [b]${args[0]}[/b] und entsorgt die Leiche im Biomüll`);
}
});
bot._trigger.set("lachs", {
call: /^(.|\/)lachs/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("öhöhöhöhöhöhö");
}
});
bot._trigger.set("kaffee", {
call: /^(.|\/)kaffee/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(data.kaffee[~~(Math.random() * data.kaffee.length)]
.replace("{user}", `[b]${args[0]}[/b]`)
);
}
});
bot._trigger.set("fucken", {
call: /^(.|\/)fucken/i,
level: 0,
@ -190,17 +121,6 @@ module.exports = bot => {
}
});
bot._trigger.set("quotes", {
call: /^(.|\/)(boll|firecooler|kinski|stoll)$/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().substring(1);
e.reply(data[`quotes_${args}`][~~(Math.random() * data[`quotes_${args}`].length)]);
}
});
bot._trigger.set("spit", {
call: /^(.|\/)spit/i,
level: 0,
@ -227,17 +147,57 @@ module.exports = bot => {
}
});
bot._trigger.set("wusel", {
call: /^(.|\/)wusel/i,
bot._trigger.set("jn", {
call: /^(.|\/)jn/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`wuselt [b]${args[0]}[/b] über den Haufen.`);
e.reply(`${e.user.nick}: [b]${~~(Math.random() * 2) ? "Ja" : "Nein"}[/b]`);
}
});
bot._trigger.set("choose", {
call: /^(.|\/)choose .*/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
const args = e.message.substring(8).trim().split(",");
if (args.length < 2)
return e.reply(`${e.user.nick}: Ob du behindert bist?`);
e.reply(`${e.user.nick}: ${args[~~(Math.random() * args.length)].trim()}`);
}
});
bot._trigger.set("huehuehue", {
call: /^huehuehue$/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("huehuehue");
}
});
bot._trigger.set("woah", {
call: /woah/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
if (~~(Math.random() * 4))
e.reply(data.woahs[~~(Math.random() * data.woahs.length)]);
}
});
bot._trigger.set("REEE", {
call: /re+$/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("R".padEnd(~~(Math.random() * 20 + 10), "E"));
}
});
};

View File

@ -0,0 +1,349 @@
import sql from "../sql.js";
const data = {
abschieben: [],
kaffee: [],
tee: [],
quotes_firecooler: [],
quotes_kinski: [],
quotes_stoll: [],
quotes_boll: []
};
Object.keys(data).forEach(cur => {
sql.exec(`select \`data\` from \`useless\` where \`trigger\` = '${cur}' limit 1`, (err, row) => {
data[cur] = JSON.parse(row[0].data);
});
});
module.exports = bot => {
bot._trigger.set("abschieben", {
call: /^(.|\/)abschieben/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`schiebt [b]${args[0]}[/b] ${data.abschieben[~~(Math.random() * data.abschieben.length)]} ab.`);
}
});
bot._trigger.set("butterkaese", {
call: /^(.|\/)butterkäse/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`drischt mit einem großen Stück Butterkäse auf [b]${args[0]}[/b] ein.`);
}
});
bot._trigger.set("notschlachten", {
call: /^(.|\/)notschlachten/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`notschlachtet [b]${args[0]}[/b] und entsorgt die Leiche im Biomüll`);
}
});
bot._trigger.set("lachs", {
call: /^(.|\/)lachs/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("öhöhöhöhöhöhö");
}
});
bot._trigger.set("kaffee", {
call: /^(.|\/)kaffee/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(data.kaffee[~~(Math.random() * data.kaffee.length)]
.replace("{user}", `[b]${args[0]}[/b]`)
);
}
});
bot._trigger.set("tee", {
call: /^(.|\/)tee/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(data.tee[~~(Math.random() * data.tee.length)]
.replace("{user}", `[b]${args[0]}[/b]`)
);
}
});
bot._trigger.set("quotes", {
call: /^(.|\/)(boll|firecooler|kinski|stoll)$/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().substring(1);
e.reply(data[`quotes_${args}`][~~(Math.random() * data[`quotes_${args}`].length)]);
}
});
bot._trigger.set("wusel", {
call: /^(.|\/)wusel/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`wuselt [b]${args[0]}[/b] über den Haufen.`);
}
});
bot._trigger.set("mett", {
call: /^(.|\/)mett/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.reply(`Jamba Mettscanner: [b]${args[0]}[/b] ist zu ${~~(Math.random() * 100 + 1)}% Mett.`);
}
});
bot._trigger.set("rotenburg", {
call: /^(.|\/)rotenburg/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`verarbeitet [b]${args[0]}[/b] zu Hackfleisch.`);
}
});
bot._trigger.set("pee", {
call: /^(.|\/)pee/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`pisst in [b]${args[0]}[/b]s Gesicht.`);
}
});
bot._trigger.set("ike", {
call: /^ike/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("ike ike!");
}
});
bot._trigger.set("rip", {
call: /^rip/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("Rust in Peace");
}
});
bot._trigger.set("haram", {
call: /^(.|\/)haram/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.reply(`[b]${args[0]}[/b] ist ${(~~(Math.random() * 2) ? "haram" : "nicht haram")}.`);
}
});
bot._trigger.set("sacklutscher", {
call: /^(.|\/)lutschsack/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.reply(`[b]${e.user.nick}[/b] legt Rosen aus und lutscht den Sack von [b]${args[0]}[/b]`);
}
});
bot._trigger.set("kawaii", {
call: /kawaii/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("⌒(oo) so much kawaii");
}
});
bot._trigger.set("hurrdurr", {
call: /^hurr$/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("durr");
}
});
bot._trigger.set("fraguwe", {
call: /^uwe.*\?$/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("fuck you");
}
});
bot._trigger.set("wasser", {
call: /^(.|\/)wasser/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`kippt [b]${args[0]}[/b] einen Eimer Wasser über den Kopf.`);
}
});
bot._trigger.set("normie", {
call: /^(.|\/)normie/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.reply(`Jamba Normiescanner: [b]${args[0]}[/b] ist zu ${~~(Math.random() * 100 + 1)}% ein Normie.`);
}
});
bot._trigger.set("hyper", {
call: /^(.|\/)hyper$/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("[b]GET HYPER![/b]");
}
});
bot._trigger.set("bark", {
call: /^(.|\/)bark$/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
e.reply("BARK BARK BARK");
}
});
bot._trigger.set("meditieren", {
call: /^(.|\/)meditieren/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`meditiert zusammen mit [b]${args[0]}[/b] Metta.`);
}
});
bot._trigger.set("duden", {
call: /^(.|\/)duden/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`drischt mit einem großen Duden auf [b]${args[0]}[/b] ein.`);
}
});
bot._trigger.set("kscht", {
call: /^(.|\/)kscht/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`jagt [b]${args[0]}[/b] durch den Raum.`);
}
});
bot._trigger.set("bullenpisse", {
call: /^(.|\/)bullenpisse/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`zapft ein Fläschchen feinsten Bullenurin, verarbeitet diesen zu Red-Bull und serviert ihn [b]${args[0]}[/b] in Form einer Pfanddose.`);
}
});
bot._trigger.set("lungenkrebs", {
call: /^(.|\/)lungenkrebs/i,
level: 0,
active: true,
clients: ["irc", "tg"],
f: e => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.replyAction(`dreht [b]${args[0]}[/b] einen prall gefüllten Sargnagel mit feinstem Schwarzer Krauser.`);
}
});
};