add privthread
This commit is contained in:
parent
7458c8278c
commit
7ea1d8c322
|
@ -41,6 +41,6 @@ add_executable(xbot
|
||||||
main.cpp irc_commands.inc ircmsg.cpp settings.cpp connection.cpp
|
main.cpp irc_commands.inc ircmsg.cpp settings.cpp connection.cpp
|
||||||
snote_thread.cpp watchdog_thread.cpp write_irc.cpp
|
snote_thread.cpp watchdog_thread.cpp write_irc.cpp
|
||||||
ping_thread.cpp irc_parse_thread.cpp registration_thread.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_include_directories(xbot PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
target_link_libraries(xbot PRIVATE Boost::headers tomlplusplus_tomlplusplus eventpp PkgConfig::LIBHS)
|
target_link_libraries(xbot PRIVATE Boost::headers tomlplusplus_tomlplusplus eventpp PkgConfig::LIBHS)
|
||||||
|
|
14
main.cpp
14
main.cpp
|
@ -14,6 +14,7 @@
|
||||||
#include "self_thread.hpp"
|
#include "self_thread.hpp"
|
||||||
#include "snote_thread.hpp"
|
#include "snote_thread.hpp"
|
||||||
#include "watchdog_thread.hpp"
|
#include "watchdog_thread.hpp"
|
||||||
|
#include "priv_thread.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
@ -34,13 +35,13 @@
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
auto echo_thread(Connection& connection) -> void
|
auto echo_thread(
|
||||||
|
Connection& connection,
|
||||||
|
std::shared_ptr<PrivThread> priv_thread) -> void
|
||||||
{
|
{
|
||||||
connection.add_listener<CommandEvent>([&connection](CommandEvent& event)
|
connection.add_listener<CommandEvent>([&connection, priv_thread](CommandEvent& event)
|
||||||
{
|
{
|
||||||
if ("raw" == event.command
|
if ("raw" == event.command && priv_thread->check_command(event, "owner"))
|
||||||
and "glguy" == event.oper
|
|
||||||
and "glguy" == event.account)
|
|
||||||
{
|
{
|
||||||
connection.write_line(std::string{event.arg});
|
connection.write_line(std::string{event.arg});
|
||||||
event.handled_ = true;
|
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);
|
RegistrationThread::start(*connection, settings.password, settings.username, settings.realname, settings.nickname);
|
||||||
SnoteThread::start(*connection);
|
SnoteThread::start(*connection);
|
||||||
CommandThread::start(*connection);
|
CommandThread::start(*connection);
|
||||||
echo_thread(*connection);
|
auto const priv_thread = PrivThread::start(*connection);
|
||||||
|
echo_thread(*connection, priv_thread);
|
||||||
|
|
||||||
connection->add_listener<SnoteEvent>([](SnoteEvent& event) {
|
connection->add_listener<SnoteEvent>([](SnoteEvent& event) {
|
||||||
std::cout << "SNOTE " << static_cast<int>(event.get_tag()) << std::endl;
|
std::cout << "SNOTE " << static_cast<int>(event.get_tag()) << std::endl;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user