diff --git a/src/providers/twitch/ircmessagehandler.cpp b/src/providers/twitch/ircmessagehandler.cpp index a7f1799d0..09753caca 100644 --- a/src/providers/twitch/ircmessagehandler.cpp +++ b/src/providers/twitch/ircmessagehandler.cpp @@ -228,16 +228,24 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message) void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message, TwitchServer &server) { auto data = message->toData(); - static QRegularExpression findMessage(" USERNOTICE (#\\w+) :(.+)$"); - - auto match = findMessage.match(data); - auto target = match.captured(1); - - if (match.hasMatch()) { - this->addMessage(message, target, match.captured(2), server, true); - } 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) { + content = parameters[1]; + } + + if (msgType == "sub" || msgType == "resub" || msgType == "subgift") { + // Sub-specific message. I think it's only allowed for "resub" messages atm + if (!content.isEmpty()) { + this->addMessage(message, target, content, server, true); + } + } + auto it = tags.find("system-msg"); if (it != tags.end()) { diff --git a/src/providers/twitch/twitchmessagebuilder.cpp b/src/providers/twitch/twitchmessagebuilder.cpp index 8f1ca38b1..986317043 100644 --- a/src/providers/twitch/twitchmessagebuilder.cpp +++ b/src/providers/twitch/twitchmessagebuilder.cpp @@ -288,19 +288,10 @@ void TwitchMessageBuilder::parseUsername() // username this->userName = this->ircMessage->nick(); - if (this->userName.isEmpty()) { + if (this->userName.isEmpty() || this->args.trimSubscriberUsername) { this->userName = this->tags.value(QLatin1String("login")).toString(); } - if (this->args.trimSubscriberUsername) { - static QRegularExpression fixName("^tmi.twitch.tv\\((\\w+)\\)$"); - - auto match = fixName.match(this->userName); - if (match.hasMatch()) { - this->userName = match.captured(1); - } - } - // display name // auto displayNameVariant = this->tags.value("display-name"); // if (displayNameVariant.isValid()) {