From 25ba548e015f3be7c2724617d9258858da7cc66a Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 20 Apr 2024 23:45:41 +0500 Subject: feat: authorizing on twitch irc servers --- src/irc/client.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/irc/client.cpp') 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"); +} -- cgit v1.2.3