From 2a49844a95593ac98e919c18651320e62f276fa7 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 6 Apr 2025 17:28:47 +0400 Subject: feat: implementing lua coding --- bot/src/commands/request.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bot/src/commands/request.cpp (limited to 'bot/src/commands/request.cpp') diff --git a/bot/src/commands/request.cpp b/bot/src/commands/request.cpp new file mode 100644 index 0000000..7acc107 --- /dev/null +++ b/bot/src/commands/request.cpp @@ -0,0 +1,28 @@ +#include "commands/request.hpp" + +#include + +namespace bot::command { + sol::table Request::as_lua_table(std::shared_ptr luaState) const { + sol::table o = luaState->create_table(); + + o["command_id"] = this->command_id; + if (this->subcommand_id.has_value()) { + o["subcommand_id"] = this->subcommand_id.value(); + } else { + o["subcommand_id"] = sol::lua_nil; + } + if (this->message.has_value()) { + o["message"] = this->message.value(); + } else { + o["message"] = sol::lua_nil; + } + + o["sender"] = this->user.as_lua_table(luaState); + o["channel"] = this->channel.as_lua_table(luaState); + o["channel_preference"] = this->channel_preferences.as_lua_table(luaState); + o["rights"] = this->user_rights.as_lua_table(luaState); + + return o; + } +} \ No newline at end of file -- cgit v1.2.3