diff options
| author | ilotterytea <iltsu@alright.party> | 2024-04-21 01:43:16 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-04-21 01:43:16 +0500 |
| commit | d75a5081c57c06e261b040a39078257a141864dd (patch) | |
| tree | 7481cde4cfc3c8dd695d9728b2f3b983871a974d /src/irc/client.hpp | |
| parent | edcf0fd1b942531ac0c6a6442fa5ad21096fe218 (diff) | |
feat: message handlers
Diffstat (limited to 'src/irc/client.hpp')
| -rw-r--r-- | src/irc/client.hpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/irc/client.hpp b/src/irc/client.hpp index e6846d2..6f0791f 100644 --- a/src/irc/client.hpp +++ b/src/irc/client.hpp @@ -4,6 +4,8 @@ #include <string> +#include "message.hpp" + namespace RedpilledBot { namespace IRC { class Client { @@ -13,6 +15,17 @@ namespace RedpilledBot { void run(); + template <MessageType T> + void on(typename MessageHandler<T>::fn function) { + switch (T) { + case Privmsg: + this->onPrivmsg = function; + break; + default: + break; + } + } + private: void authorize(); @@ -23,6 +36,9 @@ namespace RedpilledBot { std::string port; ix::WebSocket websocket; + + // Message handlers + typename MessageHandler<MessageType::Privmsg>::fn onPrivmsg; }; } } |
