diff options
Diffstat (limited to 'bot/src/commands')
| -rw-r--r-- | bot/src/commands/command.cpp | 1 | ||||
| -rw-r--r-- | bot/src/commands/lua.cpp | 14 | ||||
| -rw-r--r-- | bot/src/commands/lua.hpp | 2 |
3 files changed, 17 insertions, 0 deletions
diff --git a/bot/src/commands/command.cpp b/bot/src/commands/command.cpp index ba4edbe..fe794ef 100644 --- a/bot/src/commands/command.cpp +++ b/bot/src/commands/command.cpp @@ -90,6 +90,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); auto command = std::find_if( diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp index 96a9a68..1140334 100644 --- a/bot/src/commands/lua.cpp +++ b/bot/src/commands/lua.cpp @@ -362,6 +362,20 @@ namespace bot::command::lua { add_l10n_library(state); } + void add_irc_library(std::shared_ptr<sol::state> state, + const InstanceBundle &bundle) { + state->set_function("irc_join_channel", + [&bundle](const std::string &channel_name) { + return bundle.irc_client.join(channel_name); + }); + + state->set_function("irc_send_message", + [&bundle](const std::string &channel_name, + const std::string &message) { + bundle.irc_client.say(channel_name, message); + }); + } + void add_twitch_library(std::shared_ptr<sol::state> state, const Request &request, const InstanceBundle &bundle) { diff --git a/bot/src/commands/lua.hpp b/bot/src/commands/lua.hpp index 0adb75e..6391a2e 100644 --- a/bot/src/commands/lua.hpp +++ b/bot/src/commands/lua.hpp @@ -25,6 +25,8 @@ namespace bot::command::lua { const Request &request, const InstanceBundle &bundle); void add_net_library(std::shared_ptr<sol::state> state); + void add_irc_library(std::shared_ptr<sol::state> state, + const InstanceBundle &bundle); void add_base_libraries(std::shared_ptr<sol::state> state); } |
