diff options
| author | ilotterytea <iltsu@alright.party> | 2024-05-18 14:48:12 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-05-18 14:48:12 +0500 |
| commit | d1793df1eda463b10107d41785ad1d7f055ed476 (patch) | |
| tree | fd3e41c3b4a05924748ae4b762e1ae55a0bc815c /bot/src/irc/client.hpp | |
| parent | d7a2de17e9b7931f68b5b4079b1c36866a19d343 (diff) | |
upd: moved the bot part to a relative subfolder
Diffstat (limited to 'bot/src/irc/client.hpp')
| -rw-r--r-- | bot/src/irc/client.hpp | 58 |
1 files changed, 58 insertions, 0 deletions
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 <ixwebsocket/IXWebSocket.h> + +#include <string> +#include <vector> + +#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 <MessageType T> + void on(typename MessageHandler<T>::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<std::string> pool; + + std::vector<std::string> joined_channels; + + // Message handlers + typename MessageHandler<MessageType::Privmsg>::fn onPrivmsg; + }; + } +} |
