diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-12 16:54:58 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-12 16:54:58 +0500 |
| commit | 0e1b8bcdd6435ea1f1ad878a6f0813ab72259c24 (patch) | |
| tree | 103f5c25f284b2eaa002e2014b77cb2828f6da0a /bot | |
| parent | cd745390a89194fb7ae430f3bc8a73a7fc315ef0 (diff) | |
feat: irc functions for lua
Diffstat (limited to 'bot')
| -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); } |
