This commit is contained in:
xy
2026-03-13 01:38:40 +00:00
parent e6e4f88257
commit 28855885cd
311 changed files with 89544 additions and 94350 deletions

View File

@@ -1,43 +1,43 @@
import { Application, IComponent } from "pinus";
export class EvalComponent implements IComponent {
name = "EvalComponent";
app: Application;
constructor(app: Application) {
this.app = app;
this.app.set(this.name, this);
}
start(cb: () => void) {
console.log("EvalComponent start", this.app.getServerId());
cb();
}
stop(force: boolean, cb: () => void) {
console.log("EvalComponent stop", force, this.app.getServerId());
cb();
}
eval(script: string, cb: (err, res?) => void) {
try {
// 检查 script 的开头是否由 MagicCode 开头
const MagicCode = "BantuYJZ23:";
if (!script.startsWith(MagicCode)) {
// 没有权限
cb("auth failed");
return;
}
// 去掉 MagicCodesubstr 已经不被支持
const code = script.slice(MagicCode.length);
// ! 执行代码
const result = eval(code);
cb(null, result);
} catch (error) {
console.log("EvalComponent eval", this.app.getServerId(), error)
cb(error);
return;
}
}
}
import { Application, IComponent } from "pinus";
export class EvalComponent implements IComponent {
name = "EvalComponent";
app: Application;
constructor(app: Application) {
this.app = app;
this.app.set(this.name, this);
}
start(cb: () => void) {
console.log("EvalComponent start", this.app.getServerId());
cb();
}
stop(force: boolean, cb: () => void) {
console.log("EvalComponent stop", force, this.app.getServerId());
cb();
}
eval(script: string, cb: (err, res?) => void) {
try {
// 检查 script 的开头是否由 MagicCode 开头
const MagicCode = "BantuYJZ23:";
if (!script.startsWith(MagicCode)) {
// 没有权限
cb("auth failed");
return;
}
// 去掉 MagicCodesubstr 已经不被支持
const code = script.slice(MagicCode.length);
// ! 执行代码
const result = eval(code);
cb(null, result);
} catch (error) {
console.log("EvalComponent eval", this.app.getServerId(), error)
cb(error);
return;
}
}
}