89 lines
2.0 KiB
JavaScript
89 lines
2.0 KiB
JavaScript
import { getLevel } from "../admin.mjs";
|
|
import fetch from "flumm-fetch-cookies";
|
|
import user from "../user.mjs";
|
|
|
|
import vm from "vm";
|
|
|
|
let maxoutput = 750;
|
|
let context = vm.createContext({
|
|
e: null,
|
|
bot: null,
|
|
admins: null,
|
|
fetch: fetch,
|
|
user: user,
|
|
console: console
|
|
});
|
|
|
|
export default async bot => {
|
|
|
|
return [{
|
|
name: "trigger",
|
|
call: /^\.trigger/i,
|
|
level: 100,
|
|
f: async e => {
|
|
switch(e.args[0]) {
|
|
case "add":
|
|
try {
|
|
let args = e.args.slice(1);
|
|
const match = args.join` `.match(/^\/(?<regex>.*)\/(?<flags1>(?!\\)[gimy]+)?(?<flags>[gimy]+)?\s(?<cmd>.*)/).groups;
|
|
|
|
const blah = {
|
|
orig: args.join` `,
|
|
regex: match.regex,
|
|
flags: (match.flags1 ? match.flags1 : "") + (match.flags ? match.flags : ""),
|
|
cmd: match.cmd
|
|
};
|
|
|
|
console.log(
|
|
blah
|
|
);
|
|
|
|
} catch(err) {
|
|
console.error(err);
|
|
}
|
|
break;
|
|
case "del":
|
|
|
|
break;
|
|
default:
|
|
|
|
break;
|
|
}
|
|
}
|
|
}, {
|
|
name: "level",
|
|
call: /^!level (.*)/i,
|
|
active: true,
|
|
f: e => {
|
|
const user = e.message.trim().substring(7);
|
|
e.reply( JSON.stringify(getLevel(e.network, e.self.user.geti(user) || {})) );
|
|
}
|
|
}, {
|
|
name: "sandbox_debug",
|
|
call: /^\!debug (.*)/i,
|
|
active: true,
|
|
level: 100,
|
|
f: e => {
|
|
const args = e.message.trim().substring(7);
|
|
try {
|
|
context.e = e;
|
|
context.bot = bot;
|
|
context.level = getLevel;
|
|
let output = vm.runInContext(args, vm.createContext(context));
|
|
if (typeof output !== undefined && output) {
|
|
output = JSON.stringify(output);
|
|
if (output.length > maxoutput)
|
|
return e.reply(`holy fuck, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)`);
|
|
else
|
|
e.reply(output);
|
|
}
|
|
else
|
|
e.reply("false lol");
|
|
}
|
|
catch (err) {
|
|
e.reply(err.message);
|
|
}
|
|
}
|
|
}];
|
|
};
|