summaryrefslogtreecommitdiff
path: root/bot/src/commands/lua.cpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-15 04:37:23 +0500
committerilotterytea <iltsu@alright.party>2025-04-15 04:37:23 +0500
commitc788cacf1dbd88e1fc590a79d00aa88d49d18822 (patch)
treed530a920010a2156362258458fcc173e700293b9 /bot/src/commands/lua.cpp
parent2a6efa35f2720415a535765efdc2cd76f22ccd30 (diff)
feat: get localization names using bundle.localization
Diffstat (limited to 'bot/src/commands/lua.cpp')
-rw-r--r--bot/src/commands/lua.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp
index 2665b68..748a75e 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -295,7 +295,8 @@ namespace bot::command::lua {
});
}
- void add_l10n_library(std::shared_ptr<sol::state> state) {
+ void add_l10n_library(std::shared_ptr<sol::state> state,
+ const InstanceBundle &bundle) {
state->set_function(
"l10n_custom_formatted_line_request",
[](const sol::table &request, const sol::table &lines,
@@ -346,6 +347,17 @@ namespace bot::command::lua {
return line;
});
+
+ state->set_function("l10n_get_localization_names", [state, &bundle]() {
+ sol::table o = state->create_table();
+
+ auto locales = bundle.localization.get_loaded_localizations();
+
+ std::for_each(locales.begin(), locales.end(),
+ [&o](const std::string &x) { o.add(x); });
+
+ return o;
+ });
}
void add_string_library(std::shared_ptr<sol::state> state) {
@@ -472,7 +484,6 @@ namespace bot::command::lua {
add_json_library(state);
add_net_library(state);
add_string_library(state);
- add_l10n_library(state);
}
void add_chat_libraries(std::shared_ptr<sol::state> state,
@@ -482,6 +493,7 @@ namespace bot::command::lua {
lua::library::add_irc_library(state, bundle);
lua::library::add_twitch_library(state, request, bundle);
lua::library::add_db_library(state, bundle.configuration);
+ lua::library::add_l10n_library(state, bundle);
}
void add_irc_library(std::shared_ptr<sol::state> state,