summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bot/src/commands/command.cpp5
-rw-r--r--bot/src/commands/lua.cpp9
-rw-r--r--bot/src/commands/lua.hpp4
3 files changed, 14 insertions, 4 deletions
diff --git a/bot/src/commands/command.cpp b/bot/src/commands/command.cpp
index 18273e4..fe29b28 100644
--- a/bot/src/commands/command.cpp
+++ b/bot/src/commands/command.cpp
@@ -83,10 +83,7 @@ namespace bot {
std::optional<Response> CommandLoader::run(const InstanceBundle &bundle,
const Request &request) {
- lua::library::add_bot_library(this->luaState, bundle);
- lua::library::add_irc_library(this->luaState, bundle);
- lua::library::add_twitch_library(this->luaState, request, bundle);
- lua::library::add_db_library(this->luaState, bundle.configuration);
+ lua::library::add_chat_libraries(this->luaState, request, bundle);
auto command = std::find_if(
this->commands.begin(), this->commands.end(),
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp
index d02b9db..e8ac0c2 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -474,6 +474,15 @@ namespace bot::command::lua {
add_l10n_library(state);
}
+ void add_chat_libraries(std::shared_ptr<sol::state> state,
+ const Request &request,
+ const InstanceBundle &bundle) {
+ lua::library::add_bot_library(state, bundle);
+ lua::library::add_irc_library(state, bundle);
+ lua::library::add_twitch_library(state, request, bundle);
+ lua::library::add_db_library(state, bundle.configuration);
+ }
+
void add_irc_library(std::shared_ptr<sol::state> state,
const InstanceBundle &bundle) {
state->set_function("irc_join_channel",
diff --git a/bot/src/commands/lua.hpp b/bot/src/commands/lua.hpp
index ef16ade..9a5c344 100644
--- a/bot/src/commands/lua.hpp
+++ b/bot/src/commands/lua.hpp
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "bundle.hpp"
#include "commands/command.hpp"
#include "commands/response.hpp"
#include "config.hpp"
@@ -32,6 +33,9 @@ namespace bot::command::lua {
const InstanceBundle &bundle);
void add_base_libraries(std::shared_ptr<sol::state> state);
+ void add_chat_libraries(std::shared_ptr<sol::state> state,
+ const Request &request,
+ const InstanceBundle &bundle);
}
command::Response run_safe_lua_script(const Request &request,