Merge branch 'f0ckdev' into 'master'

sandbox



See merge request !15
This commit is contained in:
Flummi 2016-10-29 04:10:21 +00:00
commit b1fcf5c044
2 changed files with 28 additions and 1 deletions

View File

@ -17,7 +17,8 @@
"request": "^2.74.0",
"swig": "^1.4.2",
"uuid": "^2.0.2",
"ytdl-core": "^0.7.17"
"ytdl-core": "^0.7.17",
"safe-eval": "^0.3.0"
},
"repository": {
"type": "git",

26
src/trigger/sandbox.js Normal file
View File

@ -0,0 +1,26 @@
var safeEval = require('safe-eval');
module.exports = (lib) => {
lib.trigger.add({
name: 'sandbox',
call: /^\!js (.*)/i,
level: 100,
active: 1,
func: (e) => {
var args = e.message.match(/^\!js (.*)/i)[1];
var context = {
bot: lib.bot,
e: e
}
try {
var output = safeEval(args, context);
if(typeof(output) != undefined && output !== 'undefined' && output)
e.reply(output);
}
catch(blah) {
e.reply('f0ck you!');
}
},
desc: 'sandbox'
});
};