moar trigger
This commit is contained in:
parent
1f7a16282e
commit
47a133e862
|
@ -53,6 +53,8 @@ class tg {
|
|||
}
|
||||
format(msg) {
|
||||
return ""+msg
|
||||
.replace("<", "<")
|
||||
.replace(">", ">")
|
||||
.replace(/\[b\](.*?)\[\/b\]/g, "<b>$1</b>") // bold
|
||||
.replace(/\[i\](.*?)\[\/i\]/g, "<i>$1</i>") // italic
|
||||
;
|
||||
|
|
|
@ -15,7 +15,8 @@ module.exports = bot => {
|
|||
f: e => {
|
||||
const args = e.message.substring(3);
|
||||
const context = {
|
||||
e: e
|
||||
e: e,
|
||||
t: bot._trigger
|
||||
};
|
||||
try {
|
||||
let output = vm.runInNewContext(args, context);
|
||||
|
@ -32,79 +33,85 @@ module.exports = bot => {
|
|||
}
|
||||
});
|
||||
|
||||
bot._trigger.set("sandbox_hs", {
|
||||
call: /^\!hs (.*)/i,
|
||||
level: 100,
|
||||
active: true,
|
||||
clients: ["irc", "tg"],
|
||||
f: e => {
|
||||
const args = e.message.substring(4);
|
||||
const params = querystring.stringify({
|
||||
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": "main = " + args,
|
||||
"Program": "main = " + 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 = {
|
||||
hostname: "rextester.com",
|
||||
port: 80,
|
||||
path: "/rundotnet/api",
|
||||
url: "http://rextester.com/rundotnet/api",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Content-Length": Buffer.byteLength(params)
|
||||
}
|
||||
body: langs[lang],
|
||||
json: true
|
||||
};
|
||||
|
||||
const req = http.request(options, res => {
|
||||
let content = "";
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', chunk => content += chunk.toString());
|
||||
res.on('end', () => {
|
||||
content = JSON.parse(content);
|
||||
e.reply(content.Errors ? content.Errors : (content.Result.length > maxoutput) ? `holy fuck, Ausgabe wäre viel zu lang! (${content.Result.length} Zeichen :DDDDDD)` : content.Result);
|
||||
});
|
||||
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);
|
||||
});
|
||||
req.write(params);
|
||||
req.end();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
bot._trigger.set("sandbox_py", {
|
||||
call: /^\!py (.*)/i,
|
||||
bot._trigger.set("sandbox", {
|
||||
call: /^\!(hs|py|cpp|bf|php|lua) .*/i,
|
||||
level: 100,
|
||||
active: true,
|
||||
clients: ["irc", "tg"],
|
||||
f: e => {
|
||||
const args = e.message.substring(4);
|
||||
const params = querystring.stringify({
|
||||
"LanguageChoice": "24",
|
||||
"Program": "print("+args+")",
|
||||
"Input": "",
|
||||
"CompilerArgs": ""
|
||||
});
|
||||
const options = {
|
||||
hostname: "rextester.com",
|
||||
port: 80,
|
||||
path: "/rundotnet/api",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Content-Length": Buffer.byteLength(params)
|
||||
}
|
||||
};
|
||||
let args = e.message.trim().substring(1).split(" ");
|
||||
const lang = args.shift();
|
||||
args = args.join(" ");
|
||||
|
||||
const req = http.request(options, res => {
|
||||
let content = "";
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', chunk => content += chunk.toString());
|
||||
res.on('end', () => {
|
||||
content = JSON.parse(content);
|
||||
e.reply(content.Errors ? content.Errors : (content.Result.length > maxoutput) ? `holy fuck, Ausgabe wäre viel zu lang! (${content.Result.length} Zeichen :DDDDDD)` : content.Result);
|
||||
});
|
||||
});
|
||||
req.write(params);
|
||||
req.end();
|
||||
sandbox(lang, args).then(
|
||||
resolve => e.reply(resolve),
|
||||
reject => e.reply(reject.replace("\n", " "))
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -5,7 +5,12 @@ const data = {
|
|||
kill_templates: [],
|
||||
kill_parts: {},
|
||||
abschieben: [],
|
||||
kaffee: []
|
||||
kaffee: [],
|
||||
quotes_firecooler: [],
|
||||
quotes_kinski: [],
|
||||
quotes_stoll: [],
|
||||
quotes_boll: [],
|
||||
genders: []
|
||||
};
|
||||
|
||||
Object.keys(data).forEach(cur => {
|
||||
|
@ -158,4 +163,81 @@ module.exports = bot => {
|
|||
);
|
||||
}
|
||||
});
|
||||
|
||||
bot._trigger.set("fucken", {
|
||||
call: /^(.|\/)fucken/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(`fuckt [b]${args[0]}[/b] und tötet [b]${args[0]}[/b] anschließend.`);
|
||||
}
|
||||
});
|
||||
|
||||
bot._trigger.set("hack", {
|
||||
call: /^(.|\/)hack/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(`hacking ${args[0]}...`);
|
||||
}
|
||||
});
|
||||
|
||||
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,
|
||||
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(`spits on [b]${args[0]}[/b] like a dirty whore.`);
|
||||
}
|
||||
});
|
||||
|
||||
bot._trigger.set("assume", {
|
||||
call: /^(.|\/)assume/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(`Assuming [b]${args[0]}'s[/b] gender... they're a ${data.genders[~~(Math.random() * data.genders.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.`);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
Loading…
Reference in New Issue
Block a user