xbot/self_thread.hpp

40 lines
1.1 KiB
C++
Raw Permalink Normal View History

2023-11-26 16:48:21 -08:00
#pragma once
#include <memory>
2024-03-03 12:27:36 -08:00
#include <string>
#include <unordered_set>
2023-11-26 16:48:21 -08:00
struct Connection;
2024-03-03 12:53:59 -08:00
struct IrcMsg;
2023-11-26 16:48:21 -08:00
2024-03-03 12:27:36 -08:00
/**
* @brief Thread to track this connection's identity, and IRC state.
*
*/
2023-11-26 16:48:21 -08:00
class SelfThread
{
Connection& connection_;
std::string nickname_;
std::string mode_;
2024-03-03 12:27:36 -08:00
std::unordered_set<std::string> channels_;
2023-11-26 16:48:21 -08:00
2024-03-03 12:53:59 -08:00
auto on_welcome(IrcMsg const& irc) -> void;
auto on_nick(IrcMsg const& irc) -> void;
auto on_umodeis(IrcMsg const& irc) -> void;
auto on_join(IrcMsg const& irc) -> void;
auto on_kick(IrcMsg const& irc) -> void;
auto on_part(IrcMsg const& irc) -> void;
auto on_mode(IrcMsg const& irc) -> void;
2023-11-26 16:48:21 -08:00
public:
SelfThread(Connection& connection) : connection_{connection} {}
static auto start(Connection&) -> std::shared_ptr<SelfThread>;
2024-03-03 12:27:36 -08:00
auto get_my_nickname() const -> std::string const&;
auto get_my_mode() const -> std::string const&;
auto get_my_channels() const -> std::unordered_set<std::string> const&;
auto is_my_nick(std::string_view nick) const -> bool;
auto is_my_mask(std::string_view nick) const -> bool;
2023-11-26 16:48:21 -08:00
};