From d1793df1eda463b10107d41785ad1d7f055ed476 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 18 May 2024 14:48:12 +0500 Subject: upd: moved the bot part to a relative subfolder --- bot/src/irc/client.hpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 bot/src/irc/client.hpp (limited to 'bot/src/irc/client.hpp') diff --git a/bot/src/irc/client.hpp b/bot/src/irc/client.hpp new file mode 100644 index 0000000..cff867f --- /dev/null +++ b/bot/src/irc/client.hpp @@ -0,0 +1,58 @@ +#pragma once + +#include + +#include +#include + +#include "message.hpp" + +namespace bot { + namespace irc { + class Client { + public: + Client(std::string client_id, std::string token); + ~Client() = default; + + void run(); + + void say(const std::string &channel_login, const std::string &message); + bool join(const std::string &channel_login); + void raw(const std::string &raw_message); + + template + void on(typename MessageHandler::fn function) { + switch (T) { + case Privmsg: + this->onPrivmsg = function; + break; + default: + break; + } + } + + const std::string &get_bot_username() const { return this->username; }; + const int &get_bot_id() const { return this->id; } + + private: + void authorize(); + + std::string client_id, token, username; + + std::string host; + std::string port; + + int id; + + ix::WebSocket websocket; + + bool is_connected = false; + std::vector pool; + + std::vector joined_channels; + + // Message handlers + typename MessageHandler::fn onPrivmsg; + }; + } +} -- cgit v1.2.3