summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-04-20 23:22:45 +0500
committerilotterytea <iltsu@alright.party>2024-04-20 23:22:45 +0500
commit9953a68a5d1918ad6e77a7c614279d14ab1c6bc0 (patch)
treed1e70937671e9aafbde36fa7b8406f92ed0343a0 /src/irc
parentf80792c6e0e0ef167132ccec65105bb6a422031f (diff)
feat: connecting to twitch irc servers
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/client.cpp29
-rw-r--r--src/irc/client.hpp2
2 files changed, 31 insertions, 0 deletions
diff --git a/src/irc/client.cpp b/src/irc/client.cpp
index a4a2e5c..470bad9 100644
--- a/src/irc/client.cpp
+++ b/src/irc/client.cpp
@@ -1,5 +1,9 @@
#include "client.hpp"
+#include <ixwebsocket/IXWebSocketMessage.h>
+#include <ixwebsocket/IXWebSocketMessageType.h>
+
+#include <iostream>
#include <string>
using namespace RedpilledBot::IRC;
@@ -13,3 +17,28 @@ Client::Client(std::string username, std::string password) {
this->websocket.setUrl(this->host + ":" + this->port);
}
+
+void Client::run() {
+ this->websocket.setOnMessageCallback(
+ [this](const ix::WebSocketMessagePtr &msg) {
+ switch (msg->type) {
+ case ix::WebSocketMessageType::Message: {
+ std::cout << "Got a message: " << msg->str << std::endl;
+ break;
+ }
+ case ix::WebSocketMessageType::Open: {
+ std::cout << "Connected to Twitch IRC!\n";
+ break;
+ }
+ case ix::WebSocketMessageType::Close: {
+ std::cout << "Twitch IRC Connection closed!\n";
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ });
+
+ this->websocket.run();
+}
diff --git a/src/irc/client.hpp b/src/irc/client.hpp
index 18e9854..52c8cbf 100644
--- a/src/irc/client.hpp
+++ b/src/irc/client.hpp
@@ -11,6 +11,8 @@ namespace RedpilledBot {
Client(std::string username, std::string password);
~Client() = default;
+ void run();
+
private:
std::string username;
std::string password;