diff --git a/CHANGELOG.md b/CHANGELOG.md index bf95bf198..b89c9e6bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Bugfix: Added missing Copy/Open link context menu entries to emotes in Emote Picker. (#2670) - Bugfix: Fixed visual glitch with smooth scrolling. (#2084) - Bugfix: Clicking on split header focuses its split. (#2720) +- Bugfix: Handle new user messages ("rituals") properly. (#2703) ## 2.3.0 diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index 884a4ec92..ceeecc274 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -23,6 +23,16 @@ namespace { using namespace chatterino; + +// Message types below are the ones that might contain special user's message on USERNOTICE +static const QSet specialMessageTypes{ + "sub", // + "subgift", // + "resub", // resub messages + "bitsbadgetier", // bits badge upgrade + "ritual", // new viewer ritual +}; + MessagePtr generateBannedMessage(bool confirmedBan) { const auto linkColor = MessageColor(MessageColor::Link); @@ -561,12 +571,9 @@ std::vector IrcMessageHandler::parseUserNoticeMessage( { std::vector builtMessages; - auto data = message->toData(); - auto tags = message->tags(); auto parameters = message->parameters(); - auto target = parameters[0]; QString msgType = tags.value("msg-id", "").toString(); QString content; if (parameters.size() >= 2) @@ -574,11 +581,9 @@ std::vector IrcMessageHandler::parseUserNoticeMessage( content = parameters[1]; } - if (msgType == "sub" || msgType == "resub" || msgType == "subgift" || - msgType == "bitsbadgetier") + if (specialMessageTypes.contains(msgType)) { - // Sub-specific and bits badge upgrade specific message. - // It's only allowed for "resub" messages. + // Messages are not required, so they might be empty if (!content.isEmpty()) { MessageParseArgs args; @@ -596,6 +601,7 @@ std::vector IrcMessageHandler::parseUserNoticeMessage( if (it != tags.end()) { + // By default, we return value of system-msg tag QString messageText = it.value().toString(); if (msgType == "bitsbadgetier") @@ -620,8 +626,6 @@ std::vector IrcMessageHandler::parseUserNoticeMessage( void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message, TwitchIrcServer &server) { - auto data = message->toData(); - auto tags = message->tags(); auto parameters = message->parameters(); @@ -633,11 +637,9 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message, content = parameters[1]; } - if (msgType == "sub" || msgType == "resub" || msgType == "subgift" || - msgType == "bitsbadgetier") + if (specialMessageTypes.contains(msgType)) { - // Sub-specific and bits badge upgrade specific message. - // It's only allowed for "resub" messages. + // Messages are not required, so they might be empty if (!content.isEmpty()) { this->addMessage(message, target, content, server, true, false); @@ -648,6 +650,7 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message, if (it != tags.end()) { + // By default, we return value of system-msg tag QString messageText = it.value().toString(); if (msgType == "bitsbadgetier")