From 984af51e7935e997d58717cd96d08efc43abc6e7 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 15 Apr 2025 04:38:28 +0500 Subject: feat: str_to_feature function --- bot/src/commands/lua.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'bot/src/commands') 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 state, -- cgit v1.2.3