sandbox fix
This commit is contained in:
parent
b62a4c081c
commit
b236de177d
|
@ -6,19 +6,13 @@ import rp from "request-promise";
|
|||
import stringify from "stringify-object";
|
||||
|
||||
let _contexts = new Map();
|
||||
/*sql.any("select data from useless where trigger = 'sandbox_js'")
|
||||
.then(rows => {
|
||||
eval("_contexts = new Map([..."+JSON.parse(rows[0].data)+"])");
|
||||
}).catch(err => console.log("nichts vorhanden lol", err));*/
|
||||
|
||||
sql.any("select sandbox from nxy_users where sandbox != NULL")
|
||||
.then(rows => {
|
||||
eval("_contexts.set(rows[0].prefix, "+JSON.parse(rows[0].data)+");");
|
||||
}).catch(err => console.log("nichts vorhanden lol", err));
|
||||
sql.any("select prefix, sandbox from nxy_users where sandbox != 'NULL'")
|
||||
.then(rows => rows.forEach(row => eval(`_contexts.set(row.prefix, ${JSON.parse(row.sandbox)});`)))
|
||||
.catch(err => console.log("nichts vorhanden lol", err));
|
||||
|
||||
export default bot => {
|
||||
bot._trigger.set("sandbox_js", new bot.trigger({
|
||||
call: /^\.js (.*)/i,
|
||||
call: /^(\.|\/)js (.*)/i,
|
||||
set: "uwe",
|
||||
f: e => {
|
||||
const args = e.message.trim().substring(4);
|
||||
|
@ -37,23 +31,15 @@ export default bot => {
|
|||
return e.reply(`holy fuck, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)`);
|
||||
else {
|
||||
_contexts.set(e.user.prefix, context);
|
||||
let tmp = JSON.stringify(stringify([..._contexts])
|
||||
let tmp = JSON.stringify(stringify(_contexts.get(e.user.prefix))
|
||||
.replace(/\n/g, "")
|
||||
.replace(/\t/g, "")
|
||||
.split("[native code]").join(""));
|
||||
//sql.any("update useless set data = $1 where trigger = 'sandbox_js';", [tmp])
|
||||
//insert into nxy_users (nick, ${mode}) values (lower($1), $2) on conflict (nick) do update set ${mode} = excluded.${mode}
|
||||
sql.any("insert into nxy_users (nick, prefix, sandbox) values (lower($1), $3, $2) on conflict (prefix) do update set sandbox = $2, nick = lower($1)", [
|
||||
(e.type === "tg"?e.user.username || e.user.nick:e.user.nick),
|
||||
tmp,
|
||||
e.user.prefix
|
||||
])
|
||||
.then(() => {
|
||||
e.reply(output);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
(e.type === "tg" ? e.user.username || e.user.nick:e.user.nick), tmp, e.user.prefix
|
||||
]).then(() => {
|
||||
e.reply(output);
|
||||
}).catch(err => console.log(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user