outsourced trigger

This commit is contained in:
Flummi
2017-11-20 17:30:20 +01:00
parent 98da8051f0
commit 0d3d5f7c8a
6 changed files with 120 additions and 48 deletions

View File

@ -0,0 +1,22 @@
const Dest = [
"nach Syrien", "in die Ukraine", "nach Timbuktu", "nach Uruguay",
"nach Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch",
"nach Bagdad", "nach Nordkorea", "nach Kurdistan", "nach Bayern",
"nach Japan", "nach Irak", "in den Iran", "nach Saudi-Arabien",
"nach Libyen", "nach Niger", "nach Uganda", "nach Afghanistan"
];
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 ${args[0]} ${Dest[~~(Math.random() * Dest.length)]} ab.`);
}
});
};

View File

@ -0,0 +1,14 @@
module.exports = bot => {
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 ${args[0]} ein.`);
}
});
};

19
src/inc/trigger/kaffee.js Normal file
View File

@ -0,0 +1,19 @@
const texte = [
`einen frisch gebrühten Kaffee aus aromatisch hochwertigen und laktosefreien Kaffeebohnen, die nach dem Vorbild der kolonisierten Ausbeutung herangewachsen und importiert worden sind`,
`einen frisch gebrühten Kaffee aus aromatisch minderwertigen Kaffeebohnen, die zu einem überhöhten Preis und nach dem Prinzip des Fairtrade® herangewachsen und importiert worden sind`
];
module.exports = bot => {
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(`serviert ${args.join(" ")} ${texte[~~(Math.random() * texte.length)]}; Prost!`);
}
});
};

View File

@ -0,0 +1,29 @@
const vm = require("vm");
module.exports = bot => {
bot._trigger.set("sandbox", {
call: /^\!js (.*)/i,
level: 100,
active: true,
clients: ["irc", "tg"],
f: e => {
const args = e.message.substring(3);
const context = {
e: e,
b: bot
};
try {
let output = vm.runInNewContext(args, context);
if (typeof output !== undefined && output) {
output = JSON.stringify(output);
if (output !== "Converting circular structure to JSON") {
e.reply(output.length > 400 ? `holy fuck, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)` : output);
}
}
}
catch (err) {
e.reply(err.message);
}
}
});
};