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.
This commit is contained in:
Rasmus Karlsson 2019-09-21 11:38:08 +02:00
parent 8c58383298
commit 8312d4b112

View file

@ -156,6 +156,11 @@ void TwitchIrcServer::readConnectionMessageReceived(
{ {
handler.handlePartMessage(message); handler.handlePartMessage(message);
} }
else if (command == "USERSTATE")
{
// Received USERSTATE upon JOINing a channel
handler.handleUserStateMessage(message);
}
} }
void TwitchIrcServer::writeConnectionMessageReceived( void TwitchIrcServer::writeConnectionMessageReceived(
@ -168,6 +173,7 @@ void TwitchIrcServer::writeConnectionMessageReceived(
// Below commands enabled through the twitch.tv/commands CAP REQ // Below commands enabled through the twitch.tv/commands CAP REQ
if (command == "USERSTATE") if (command == "USERSTATE")
{ {
// Received USERSTATE upon PRIVMSGing
handler.handleUserStateMessage(message); handler.handleUserStateMessage(message);
} }
else if (command == "WHISPER") else if (command == "WHISPER")
@ -199,20 +205,24 @@ void TwitchIrcServer::writeConnectionMessageReceived(
void TwitchIrcServer::onReadConnected(IrcConnection *connection) 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/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/ // 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) 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/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/ // 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"); connection->sendRaw("CAP REQ :twitch.tv/tags twitch.tv/commands");
AbstractIrcServer::onWriteConnected(connection);
} }
std::shared_ptr<Channel> TwitchIrcServer::getCustomChannel( std::shared_ptr<Channel> TwitchIrcServer::getCustomChannel(