modified: src/trigger/test.js

This commit is contained in:
Flummi 2016-10-29 05:06:46 +02:00
parent 73a9a90d43
commit 6209c98c1e

View File

@ -1,11 +1,23 @@
var Sandbox = require("sandbox");
var s = new Sandbox({
timeout: 2000
});
let sbhead = "\"use strict\";";
sbhead += Object.getOwnPropertyNames(Math).map(function(v){return "const " + v + "=Math." + v + ";" + (typeof Math[v] == "function" ? v + ".bind(Math);" : "")}).join("");
module.exports = (lib) => {
lib.trigger.add({
name: 'test',
call: /^!test$/i,
level: 0,
active: 0,
call: /^!test (.*)/i,
level: 100,
active: 1,
func: (e) => {
var args = e.message.trim().match(/^!test (.*)/i)[1];
s.run(sbhead + args, (out) => {
let con = out.console.length > 0 ? " and printed to console: " + out.console : "";
let text = (out.result + con).replace(/[\r\n\t]/g, " ");
e.reply(e.user.getNick() + " it returned: " + (text.length > 400 ? "f0ck you" : text));
});
},
desc: 'muh'
});