Improve sub/resub message parsing

Instead of regexping out the username, use the existing ircv3 login-tag
This commit is contained in:
Rasmus Karlsson
2018-06-05 14:14:00 +02:00
parent 791187e688
commit 7c81477c35
2 changed files with 17 additions and 18 deletions
+16 -8
View File
@@ -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()) {