summaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/src/commands/lua.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp
index b8d0dee..589fd27 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -180,6 +180,18 @@ namespace bot::command::lua {
state->set_function("json_stringify", [](const sol::object &o) {
return lua_to_json(o).dump();
});
+
+ state->set_function("json_get_value", [state](const sol::object &body,
+ const std::string &path) {
+ std::vector<std::string> parts = utils::string::split_text(path, '.');
+ nlohmann::json o = lua_to_json(body);
+
+ for (const std::string &path : parts) {
+ o = o[path];
+ }
+
+ return parse_json_object(state, o);
+ });
}
void add_net_library(std::shared_ptr<sol::state> state) {