From 3d4bdc1cd39726949d7d25a6a2db45ada86a087a Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 6 Apr 2025 19:29:55 +0400 Subject: feat: a command for executing lua scripts --- bot/src/modules/lua.hpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bot/src/modules/lua.hpp (limited to 'bot/src/modules/lua.hpp') diff --git a/bot/src/modules/lua.hpp b/bot/src/modules/lua.hpp new file mode 100644 index 0000000..b60850a --- /dev/null +++ b/bot/src/modules/lua.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include + +#include "bundle.hpp" +#include "commands/command.hpp" +#include "commands/lua.hpp" +#include "commands/response_error.hpp" + +namespace bot::mod { + class LuaExecution : public command::Command { + std::string get_name() const override { return "lua"; } + + int get_delay_seconds() const override { return 1; } + + command::Response run(const InstanceBundle &bundle, + const command::Request &request) const override { + if (!request.message.has_value()) { + throw ResponseException( + request, bundle.localization, command::CommandArgument::VALUE); + } + + std::string script = request.message.value(); + + return command::lua::run_safe_lua_script(request, bundle, script); + } + }; +} \ No newline at end of file -- cgit v1.2.3