Download scripts/cmds/eval.js from sweet2004/bot: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/spaces/sweet2004/bot/resolve/main/scripts/cmds/eval.js
- Command line
-
hf download hf://spaces/sweet2004/bot/scripts/cmds/eval.js
-
curl -L -o eval.js https://huggingface.co/spaces/sweet2004/bot/resolve/main/scripts/cmds/eval.js
1.67 kB
| const { removeHomeDir, log } = global.utils; | |
| module.exports = { | |
| config: { | |
| name: "eval", | |
| version: "1.5", | |
| author: "NTKhang", | |
| countDown: 5, | |
| role: 2, | |
| shortDescription: { | |
| vi: "Test code nhanh", | |
| en: "Test code quickly" | |
| }, | |
| longDescription: { | |
| vi: "Test code nhanh", | |
| en: "Test code quickly" | |
| }, | |
| category: "owner", | |
| guide: { | |
| vi: "{pn} <đoạn code cần test>", | |
| en: "{pn} <code to test>" | |
| } | |
| }, | |
| langs: { | |
| vi: { | |
| error: "❌ Đã có lỗi xảy ra:" | |
| }, | |
| en: { | |
| error: "❌ An error occurred:" | |
| } | |
| }, | |
| onStart: async function ({ api, args, message, event, threadsData, usersData, dashBoardData, globalData, threadModel, userModel, dashBoardModel, globalModel, role, commandName, getLang }) { | |
| function output(msg) { | |
| if (typeof msg == "number" || typeof msg == "boolean" || typeof msg == "function") | |
| msg = msg.toString(); | |
| else if (msg instanceof Map) { | |
| let text = `Map(${msg.size}) `; | |
| text += JSON.stringify(mapToObj(msg), null, 2); | |
| msg = text; | |
| } | |
| else if (typeof msg == "object") | |
| msg = JSON.stringify(msg, null, 2); | |
| else if (typeof msg == "undefined") | |
| msg = "undefined"; | |
| message.reply(msg); | |
| } | |
| function out(msg) { | |
| output(msg); | |
| } | |
| function mapToObj(map) { | |
| const obj = {}; | |
| map.forEach(function (v, k) { | |
| obj[k] = v; | |
| }); | |
| return obj; | |
| } | |
| const cmd = ` | |
| (async () => { | |
| try { | |
| ${args.join(" ")} | |
| } | |
| catch(err) { | |
| log.err("eval command", err); | |
| message.send( | |
| "${getLang("error")}\\n" + | |
| (err.stack ? | |
| removeHomeDir(err.stack) : | |
| removeHomeDir(JSON.stringify(err, null, 2) || "") | |
| ) | |
| ); | |
| } | |
| })()`; | |
| eval(cmd); | |
| } | |
| }; |