diff options
Diffstat (limited to 'src/irc/client.cpp')
| -rw-r--r-- | src/irc/client.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/irc/client.cpp b/src/irc/client.cpp index 2604186..08a3ff3 100644 --- a/src/irc/client.cpp +++ b/src/irc/client.cpp @@ -74,6 +74,11 @@ void Client::run() { case ix::WebSocketMessageType::Close: { std::cout << "Twitch IRC Connection closed!\n"; this->is_connected = false; + + for (const auto &x : this->joined_channels) { + this->raw("JOIN #" + x); + } + break; } default: { @@ -85,6 +90,19 @@ void Client::run() { this->websocket.run(); } +bool Client::join(const std::string &channel_login) { + auto already_joined = + std::any_of(this->joined_channels.begin(), this->joined_channels.end(), + [&](const auto &x) { return x == channel_login; }); + + if (!already_joined) { + this->raw("JOIN #" + channel_login); + this->joined_channels.push_back(channel_login); + } + + return !already_joined; +} + void Client::raw(const std::string &raw_message) { std::string msg = raw_message + "\r\n"; if (this->is_connected) { |
