feat: indicate multi-month subs and resubs (#5642)

This commit is contained in:
iProdigy
2024-10-12 04:40:33 -05:00
committed by GitHub
parent 9f196c67ea
commit bdc12ffb3f
3 changed files with 69 additions and 0 deletions
@@ -566,6 +566,37 @@ std::vector<MessagePtr> parseUserNoticeMessage(Channel *channel,
}
}
}
else if (msgType == "sub" || msgType == "resub")
{
if (auto tenure = tags.find("msg-param-multimonth-tenure");
tenure != tags.end() && tenure.value().toInt() == 0)
{
int months =
tags.value("msg-param-multimonth-duration").toInt();
if (months > 1)
{
int tier = tags.value("msg-param-sub-plan").toInt() / 1000;
messageText =
QString(
"%1 subscribed at Tier %2 for %3 months in advance")
.arg(tags.value("display-name").toString(),
QString::number(tier),
QString::number(months));
if (msgType == "resub")
{
int cumulative =
tags.value("msg-param-cumulative-months").toInt();
messageText +=
QString(", reaching %1 months cumulatively so far!")
.arg(QString::number(cumulative));
}
else
{
messageText += "!";
}
}
}
}
auto b = MessageBuilder(systemMessage, parseTagString(messageText),
calculateMessageTime(message).time());
@@ -1084,6 +1115,37 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message,
}
}
}
else if (msgType == "sub" || msgType == "resub")
{
if (auto tenure = tags.find("msg-param-multimonth-tenure");
tenure != tags.end() && tenure.value().toInt() == 0)
{
int months =
tags.value("msg-param-multimonth-duration").toInt();
if (months > 1)
{
int tier = tags.value("msg-param-sub-plan").toInt() / 1000;
messageText =
QString(
"%1 subscribed at Tier %2 for %3 months in advance")
.arg(tags.value("display-name").toString(),
QString::number(tier),
QString::number(months));
if (msgType == "resub")
{
int cumulative =
tags.value("msg-param-cumulative-months").toInt();
messageText +=
QString(", reaching %1 months cumulatively so far!")
.arg(QString::number(cumulative));
}
else
{
messageText += "!";
}
}
}
}
auto b = MessageBuilder(systemMessage, parseTagString(messageText),
calculateMessageTime(message).time());