summaryrefslogtreecommitdiff
path: root/bot/src/commands/lua.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bot/src/commands/lua.cpp')
-rw-r--r--bot/src/commands/lua.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp
index 90b734e..cb00887 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -17,6 +17,7 @@
#include <string>
#include <vector>
+#include "api/kick.hpp"
#include "api/twitch/schemas/user.hpp"
#include "bundle.hpp"
#include "commands/request.hpp"
@@ -610,6 +611,7 @@ namespace bot::command::lua {
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_kick_library(state, bundle);
lua::library::add_db_library(state, bundle.configuration);
lua::library::add_l10n_library(state, bundle);
}
@@ -702,6 +704,29 @@ namespace bot::command::lua {
return o;
});
}
+
+ void add_kick_library(std::shared_ptr<sol::state> state,
+ const InstanceBundle &bundle) {
+ state->set_function(
+ "kick_get_channels", [state, &bundle](const std::string &slug) {
+ std::vector<api::KickChannel> channels =
+ bundle.kick_api_client.get_channels(slug);
+
+ sol::table o = state->create_table();
+
+ std::for_each(channels.begin(), channels.end(),
+ [state, &o](const api::KickChannel &x) {
+ sol::table u = state->create_table();
+
+ u["id"] = x.broadcaster_user_id;
+ u["login"] = x.slug;
+
+ o.add(u);
+ });
+
+ return o;
+ });
+ }
}
Response parse_lua_response(const sol::table &r, sol::object &res,