diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-06 19:29:55 +0400 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-06 19:29:55 +0400 |
| commit | 3d4bdc1cd39726949d7d25a6a2db45ada86a087a (patch) | |
| tree | 21d897aeb87cb7e8149f8f78b05459f20ba7a34e /bot/src/modules/lua.hpp | |
| parent | d1fcac7411bd0a686c3ccaa7416d98dc197c4e59 (diff) | |
feat: a command for executing lua scripts
Diffstat (limited to 'bot/src/modules/lua.hpp')
| -rw-r--r-- | bot/src/modules/lua.hpp | 28 |
1 files changed, 28 insertions, 0 deletions
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 <string> + +#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<ResponseError::NOT_ENOUGH_ARGUMENTS>( + 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 |
