diff options
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/src/commands/command.cpp | 1 | ||||
| -rw-r--r-- | bot/src/commands/lua.cpp | 9 | ||||
| -rw-r--r-- | bot/src/commands/lua.hpp | 2 |
3 files changed, 12 insertions, 0 deletions
diff --git a/bot/src/commands/command.cpp b/bot/src/commands/command.cpp index 4ec8e59..ba4edbe 100644 --- a/bot/src/commands/command.cpp +++ b/bot/src/commands/command.cpp @@ -89,6 +89,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_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 571fdb5..96a9a68 100644 --- a/bot/src/commands/lua.cpp +++ b/bot/src/commands/lua.cpp @@ -76,6 +76,15 @@ namespace bot::command::lua { }); } + void add_bot_library(std::shared_ptr<sol::state> state, + const InstanceBundle &bundle) { + state->set_function("bot_username", [&bundle]() { + return bundle.irc_client.get_bot_username(); + }); + + add_bot_library(state); + } + void add_time_library(std::shared_ptr<sol::state> state) { state->set_function("time_current", []() { return static_cast<long long>( diff --git a/bot/src/commands/lua.hpp b/bot/src/commands/lua.hpp index 9853b27..0adb75e 100644 --- a/bot/src/commands/lua.hpp +++ b/bot/src/commands/lua.hpp @@ -17,6 +17,8 @@ void print_lua_object_type(const sol::object &obj); namespace bot::command::lua { namespace library { void add_bot_library(std::shared_ptr<sol::state> state); + void add_bot_library(std::shared_ptr<sol::state> state, + const InstanceBundle &bundle); void add_time_library(std::shared_ptr<sol::state> state); void add_json_library(std::shared_ptr<sol::state> state); void add_twitch_library(std::shared_ptr<sol::state> state, |
