feat: report duration for multi-month anon sub gifts (#5293)

This commit is contained in:
iProdigy
2024-04-02 03:50:53 -07:00
committed by GitHub
parent 2a447d3c95
commit 92e75784fc
3 changed files with 49 additions and 0 deletions
@@ -53,6 +53,8 @@ const QSet<QString> SPECIAL_MESSAGE_TYPES{
"viewermilestone", // watch streak, but other categories possible in future
};
const QString ANONYMOUS_GIFTER_ID = "274598607";
MessagePtr generateBannedMessage(bool confirmedBan)
{
const auto linkColor = MessageColor(MessageColor::Link);
@@ -516,6 +518,26 @@ std::vector<MessagePtr> parseUserNoticeMessage(Channel *channel,
{
messageText = "Announcement";
}
else if (msgType == "subgift" &&
ANONYMOUS_GIFTER_ID == tags.value("user-id").toString())
{
if (auto monthsIt = tags.find("msg-param-gift-months");
monthsIt != tags.end())
{
int months = monthsIt.value().toInt();
if (months > 1)
{
auto plan = tags.value("msg-param-sub-plan").toString();
messageText =
QString("An anonymous user gifted %1 months of a Tier "
"%2 sub to %3!")
.arg(QString::number(months),
plan.isEmpty() ? '1' : plan.at(0),
tags.value("msg-param-recipient-display-name")
.toString());
}
}
}
auto b = MessageBuilder(systemMessage, parseTagString(messageText),
calculateMessageTime(message).time());
@@ -1010,6 +1032,26 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message,
{
messageText = "Announcement";
}
else if (msgType == "subgift" &&
ANONYMOUS_GIFTER_ID == tags.value("user-id").toString())
{
if (auto monthsIt = tags.find("msg-param-gift-months");
monthsIt != tags.end())
{
int months = monthsIt.value().toInt();
if (months > 1)
{
auto plan = tags.value("msg-param-sub-plan").toString();
messageText =
QString("An anonymous user gifted %1 months of a Tier "
"%2 sub to %3!")
.arg(QString::number(months),
plan.isEmpty() ? '1' : plan.at(0),
tags.value("msg-param-recipient-display-name")
.toString());
}
}
}
auto b = MessageBuilder(systemMessage, parseTagString(messageText),
calculateMessageTime(message).time());