xbot/priv_thread.hpp
2023-11-29 13:13:48 -08:00

34 lines
926 B
C++

#pragma once
#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
class Connection;
class CommandEvent;
class PrivThread : std::enable_shared_from_this<PrivThread>
{
Connection& connection_;
std::string config_path_;
std::unordered_map<std::string, std::unordered_set<std::string>> oper_privs_;
std::unordered_map<std::string, std::unordered_set<std::string>> account_privs_;
auto on_command(CommandEvent&) -> void;
auto load_config() -> void;
auto save_config() -> void;
auto list_privs(std::string_view nick) -> void;
public:
PrivThread(Connection&, std::string config_path);
auto check_command(CommandEvent& event, std::string priv) -> bool;
static constexpr char const* owner_priv = "owner";
static constexpr char const* wildcard = "*";
static auto start(Connection&, std::string config_path) -> std::shared_ptr<PrivThread>;
};