summaryrefslogtreecommitdiff
path: root/bot/src
diff options
context:
space:
mode:
Diffstat (limited to 'bot/src')
-rw-r--r--bot/src/bundle.hpp10
-rw-r--r--bot/src/commands/lua.cpp14
-rw-r--r--bot/src/main.cpp3
3 files changed, 26 insertions, 1 deletions
diff --git a/bot/src/bundle.hpp b/bot/src/bundle.hpp
index d30f5f8..6f29a50 100644
--- a/bot/src/bundle.hpp
+++ b/bot/src/bundle.hpp
@@ -1,6 +1,15 @@
#pragma once
+namespace bot {
+ namespace command {
+ class CommandLoader;
+ }
+
+ class InstanceBundle;
+}
+
#include "api/twitch/helix_client.hpp"
+#include "commands/command.hpp"
#include "config.hpp"
#include "irc/client.hpp"
#include "localization/localization.hpp"
@@ -11,5 +20,6 @@ namespace bot {
const api::twitch::HelixClient &helix_client;
const bot::loc::Localization &localization;
const Configuration &configuration;
+ const command::CommandLoader &command_loader;
};
}
diff --git a/bot/src/commands/lua.cpp b/bot/src/commands/lua.cpp
index cab5cb4..4723311 100644
--- a/bot/src/commands/lua.cpp
+++ b/bot/src/commands/lua.cpp
@@ -84,6 +84,20 @@ namespace bot::command::lua {
return bundle.irc_client.get_bot_username();
});
+ state->set_function("bot_get_loaded_command_names", [state, &bundle]() {
+ sol::table o = state->create_table();
+
+ const std::vector<std::unique_ptr<Command>> &commands =
+ bundle.command_loader.get_commands();
+
+ std::for_each(commands.begin(), commands.end(),
+ [&o](const std::unique_ptr<Command> &command) {
+ o.add(command->get_name());
+ });
+
+ return o;
+ });
+
add_bot_library(state);
}
diff --git a/bot/src/main.cpp b/bot/src/main.cpp
index 212d190..360e243 100644
--- a/bot/src/main.cpp
+++ b/bot/src/main.cpp
@@ -112,7 +112,8 @@ int main(int argc, char *argv[]) {
client.on<bot::irc::MessageType::Privmsg>(
[&client, &command_loader, &localization, &cfg, &helix_client](
const bot::irc::Message<bot::irc::MessageType::Privmsg> &message) {
- bot::InstanceBundle bundle{client, helix_client, localization, cfg};
+ bot::InstanceBundle bundle{client, helix_client, localization, cfg,
+ command_loader};
pqxx::connection conn(GET_DATABASE_CONNECTION_URL(cfg));