summaryrefslogtreecommitdiff
path: root/bot/src/commands/lua.cpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-15 04:38:28 +0500
committerilotterytea <iltsu@alright.party>2025-04-15 04:38:28 +0500
commit984af51e7935e997d58717cd96d08efc43abc6e7 (patch)
tree3f37f88c402e5d879f33832bc99255fc88b27116 /bot/src/commands/lua.cpp
parent78cdcc4273f0c0f0740bafe40443be0b4ec9fe5b (diff)
feat: str_to_feature function
Diffstat (limited to 'bot/src/commands/lua.cpp')
-rw-r--r--bot/src/commands/lua.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp
index 783b48b..22233bb 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -27,6 +27,7 @@
#include "cpr/cprtypes.h"
#include "cpr/multipart.h"
#include "cpr/response.h"
+#include "schemas/channel.hpp"
#include "schemas/user.hpp"
#include "utils/chrono.hpp"
#include "utils/string.hpp"
@@ -365,6 +366,16 @@ namespace bot::command::lua {
[](const std::string &text, const char &delimiter) {
return utils::string::split_text(text, delimiter);
});
+
+ state->set_function(
+ "str_to_feature", [state](const std::string &feature) {
+ auto f = schemas::string_to_channel_feature(feature);
+ if (f.has_value()) {
+ return sol::make_object(*state, (int)f.value());
+ } else {
+ return sol::make_object(*state, sol::lua_nil);
+ }
+ });
}
void add_db_library(std::shared_ptr<sol::state> state,