summaryrefslogtreecommitdiff
path: root/bot/src/commands/lua.cpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-09 21:54:40 +0500
committerilotterytea <iltsu@alright.party>2025-04-09 21:54:40 +0500
commitf2bf41bc614c7b070649a29b6fe9ca48cc1eafbb (patch)
treebadaf7067a0d0206c7892f696f7350f5021ca8a1 /bot/src/commands/lua.cpp
parentb89a39dcda1f31e1105768724c0efb36c612bebe (diff)
feat: bot_config() function for lua
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 6c20b15..7f70e68 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -54,6 +54,17 @@ namespace bot::command::lua {
[]() { return BOT_COMPILED_TIMESTAMP; });
state->set_function("bot_get_version", []() { return BOT_VERSION; });
+
+ state->set_function("bot_config", [state]() {
+ std::optional<bot::Configuration> o_cfg =
+ bot::parse_configuration_from_file(".env");
+
+ if (!o_cfg.has_value()) {
+ return sol::make_object(*state, sol::nil);
+ }
+
+ return sol::make_object(*state, o_cfg->as_lua_table(state));
+ });
}
void add_time_library(std::shared_ptr<sol::state> state) {