new sandbox
This commit is contained in:
20
src/bot.js
20
src/bot.js
@ -1,7 +1,7 @@
|
||||
import { logger } from "./inc/log.js";
|
||||
import { read } from "./inc/cfg.js";
|
||||
import { wrapper, clients } from "./inc/wrapper.js";
|
||||
const safeEval = require("safe-eval");
|
||||
const vm = require("vm");
|
||||
|
||||
read().then(() => {
|
||||
let bot = new wrapper();
|
||||
@ -14,20 +14,16 @@ read().then(() => {
|
||||
|
||||
if (e.message.match(/^\.js /)) { // JS-Sandbox
|
||||
args = e.message.substring(3);
|
||||
var context = {
|
||||
const context = {
|
||||
e: e,
|
||||
gf: "nogf",
|
||||
c: clients,
|
||||
console: {
|
||||
log: console.log
|
||||
}
|
||||
c: clients
|
||||
};
|
||||
try {
|
||||
var output = safeEval(args, context);
|
||||
if (typeof output !== undefined && output !== "undefined" && output) {
|
||||
let blah = JSON.stringify(output);
|
||||
if (blah != "Converting circular structure to JSON") {
|
||||
e.reply(blah.length > 400 ? `holy fuck, Ausgabe wäre viel zu lang! (${blah.length} Zeichen :DDDDDD)` : blah);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user