From 8312d4b1121de1ca506743d093499739621ab007 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sat, 21 Sep 2019 11:38:08 +0200 Subject: [PATCH] Fix USERSTATE not being handled unless you write in a channel. This commit might re-enable some duplicate messages like host requests and what-not. --- src/providers/twitch/TwitchIrcServer.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/providers/twitch/TwitchIrcServer.cpp b/src/providers/twitch/TwitchIrcServer.cpp index 5161f928e..63a70ed87 100644 --- a/src/providers/twitch/TwitchIrcServer.cpp +++ b/src/providers/twitch/TwitchIrcServer.cpp @@ -156,6 +156,11 @@ void TwitchIrcServer::readConnectionMessageReceived( { handler.handlePartMessage(message); } + else if (command == "USERSTATE") + { + // Received USERSTATE upon JOINing a channel + handler.handleUserStateMessage(message); + } } void TwitchIrcServer::writeConnectionMessageReceived( @@ -168,6 +173,7 @@ void TwitchIrcServer::writeConnectionMessageReceived( // Below commands enabled through the twitch.tv/commands CAP REQ if (command == "USERSTATE") { + // Received USERSTATE upon PRIVMSGing handler.handleUserStateMessage(message); } else if (command == "WHISPER") @@ -199,20 +205,24 @@ void TwitchIrcServer::writeConnectionMessageReceived( void TwitchIrcServer::onReadConnected(IrcConnection *connection) { - AbstractIrcServer::onReadConnected(connection); - // twitch.tv/tags enables IRCv3 tags on messages. See https://dev.twitch.tv/docs/irc/tags/ // twitch.tv/membership enables the JOIN/PART/MODE/NAMES commands. See https://dev.twitch.tv/docs/irc/membership/ - connection->sendRaw("CAP REQ :twitch.tv/tags twitch.tv/membership"); + // twitch.tv/commands enables a bunch of miscellaneous command capabilities. See https://dev.twitch.tv/docs/irc/commands/ + // This is enabled here so we receive USERSTATE messages when joining channels + connection->sendRaw( + "CAP REQ :twitch.tv/tags twitch.tv/membership twitch.tv/commands"); + + AbstractIrcServer::onReadConnected(connection); } void TwitchIrcServer::onWriteConnected(IrcConnection *connection) { - AbstractIrcServer::onWriteConnected(connection); - // twitch.tv/tags enables IRCv3 tags on messages. See https://dev.twitch.tv/docs/irc/tags/ // twitch.tv/commands enables a bunch of miscellaneous command capabilities. See https://dev.twitch.tv/docs/irc/commands/ + // This is enabled here so we receive USERSTATE messages when typing messages, along with the other command capabilities connection->sendRaw("CAP REQ :twitch.tv/tags twitch.tv/commands"); + + AbstractIrcServer::onWriteConnected(connection); } std::shared_ptr TwitchIrcServer::getCustomChannel(