summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-04-20 23:45:41 +0500
committerilotterytea <iltsu@alright.party>2024-04-20 23:45:41 +0500
commit25ba548e015f3be7c2724617d9258858da7cc66a (patch)
tree049cba4f10d014b8ca0ad056f410d403123c66bb /src
parent9953a68a5d1918ad6e77a7c614279d14ab1c6bc0 (diff)
feat: authorizing on twitch irc servers
Diffstat (limited to 'src')
-rw-r--r--src/irc/client.cpp16
-rw-r--r--src/irc/client.hpp2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/irc/client.cpp b/src/irc/client.cpp
index 470bad9..42fd8ac 100644
--- a/src/irc/client.cpp
+++ b/src/irc/client.cpp
@@ -28,6 +28,7 @@ void Client::run() {
}
case ix::WebSocketMessageType::Open: {
std::cout << "Connected to Twitch IRC!\n";
+ this->authorize();
break;
}
case ix::WebSocketMessageType::Close: {
@@ -42,3 +43,18 @@ void Client::run() {
this->websocket.run();
}
+
+void Client::authorize() {
+ if (this->username.empty() || this->password.empty()) {
+ std::cout << "Bot username and password must be set!\n";
+ return;
+ }
+
+ std::cout << "Authorizing on Twitch IRC servers...\n";
+
+ this->websocket.send("PASS " + this->password + "\r\n");
+ this->websocket.send("NICK " + this->username + "\r\n");
+ this->websocket.send("CAP REQ :twitch.tv/membership\r\n");
+ this->websocket.send("CAP REQ :twitch.tv/commands\r\n");
+ this->websocket.send("CAP REQ :twitch.tv/tags\r\n");
+}
diff --git a/src/irc/client.hpp b/src/irc/client.hpp
index 52c8cbf..e6846d2 100644
--- a/src/irc/client.hpp
+++ b/src/irc/client.hpp
@@ -14,6 +14,8 @@ namespace RedpilledBot {
void run();
private:
+ void authorize();
+
std::string username;
std::string password;