From fbf41a4c737174442717ade79e895321ee8ada36 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 8 Apr 2025 01:06:11 +0400 Subject: upd: add twitch lib on every command run (that's maybe bad for performance) --- bot/src/commands/command.cpp | 4 +++- bot/src/commands/command.hpp | 2 +- bot/src/handlers.cpp | 3 +-- bot/src/handlers.hpp | 3 +-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'bot') diff --git a/bot/src/commands/command.cpp b/bot/src/commands/command.cpp index 1658554..87eecfd 100644 --- a/bot/src/commands/command.cpp +++ b/bot/src/commands/command.cpp @@ -84,7 +84,9 @@ namespace bot { } std::optional CommandLoader::run(const InstanceBundle &bundle, - const Request &request) const { + const Request &request) { + lua::library::add_twitch_library(this->luaState, request, bundle); + auto command = std::find_if( this->commands.begin(), this->commands.end(), [&](const auto &x) { return x->get_name() == request.command_id; }); diff --git a/bot/src/commands/command.hpp b/bot/src/commands/command.hpp index c2398ec..fcaacdb 100644 --- a/bot/src/commands/command.hpp +++ b/bot/src/commands/command.hpp @@ -45,7 +45,7 @@ namespace bot { void add_command(std::unique_ptr cmd); void load_lua_directory(const std::string &folder_path); std::optional run(const InstanceBundle &bundle, - const Request &msg) const; + const Request &msg); const std::vector> &get_commands() const { return this->commands; diff --git a/bot/src/handlers.cpp b/bot/src/handlers.cpp index 42e1090..f8b911d 100644 --- a/bot/src/handlers.cpp +++ b/bot/src/handlers.cpp @@ -26,8 +26,7 @@ namespace bot::handlers { void handle_private_message( - const InstanceBundle &bundle, - const command::CommandLoader &command_loader, + const InstanceBundle &bundle, command::CommandLoader &command_loader, const irc::Message &message, pqxx::connection &conn) { if (utils::string::string_contains_sql_injection(message.message)) { diff --git a/bot/src/handlers.hpp b/bot/src/handlers.hpp index a78a529..2046bbe 100644 --- a/bot/src/handlers.hpp +++ b/bot/src/handlers.hpp @@ -7,8 +7,7 @@ namespace bot::handlers { void handle_private_message( - const InstanceBundle &bundle, - const command::CommandLoader &command_loader, + const InstanceBundle &bundle, command::CommandLoader &command_loader, const irc::Message &message, pqxx::connection &conn); -- cgit v1.2.3