diff --git a/CMakeLists.txt b/CMakeLists.txt index ffa1598..65bfb6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,6 @@ add_executable(xbot main.cpp irc_commands.inc ircmsg.cpp settings.cpp connection.cpp snote_thread.cpp watchdog_thread.cpp write_irc.cpp ping_thread.cpp irc_parse_thread.cpp registration_thread.cpp - self_thread.cpp command_thread.cpp) + self_thread.cpp command_thread.cpp priv_thread.cpp) target_include_directories(xbot PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(xbot PRIVATE Boost::headers tomlplusplus_tomlplusplus eventpp PkgConfig::LIBHS) diff --git a/main.cpp b/main.cpp index 38b2adf..9e37488 100644 --- a/main.cpp +++ b/main.cpp @@ -14,6 +14,7 @@ #include "self_thread.hpp" #include "snote_thread.hpp" #include "watchdog_thread.hpp" +#include "priv_thread.hpp" #include #include @@ -34,13 +35,13 @@ using namespace std::chrono_literals; -auto echo_thread(Connection& connection) -> void +auto echo_thread( + Connection& connection, + std::shared_ptr priv_thread) -> void { - connection.add_listener([&connection](CommandEvent& event) + connection.add_listener([&connection, priv_thread](CommandEvent& event) { - if ("raw" == event.command - and "glguy" == event.oper - and "glguy" == event.account) + if ("raw" == event.command && priv_thread->check_command(event, "owner")) { connection.write_line(std::string{event.arg}); event.handled_ = true; @@ -60,7 +61,8 @@ auto start(boost::asio::io_context & io, Settings const& settings) -> void RegistrationThread::start(*connection, settings.password, settings.username, settings.realname, settings.nickname); SnoteThread::start(*connection); CommandThread::start(*connection); - echo_thread(*connection); + auto const priv_thread = PrivThread::start(*connection); + echo_thread(*connection, priv_thread); connection->add_listener([](SnoteEvent& event) { std::cout << "SNOTE " << static_cast(event.get_tag()) << std::endl;