-
-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: report duration for multi-month anon sub gifts #5293
Merged
pajlada
merged 5 commits into
Chatterino:master
from
iProdigy:feature/subgift-multi-month-message
Apr 2, 2024
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ff6fb76
feat: show duration for multi month sub gift
iProdigy f2d9f7f
chore: update changelog
iProdigy 1933787
chore: only adjust anon gifts
iProdigy 717265f
chore: update sample data
iProdigy 086dfdb
fix: safely handle missing sub tier
iProdigy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,27 @@ 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) | ||
{ | ||
messageText = | ||
QString("An anonymous user gifted %1 months of a Tier " | ||
"%2 sub to %3!") | ||
.arg(QString::number(months), | ||
tags.value("msg-param-sub-plan") | ||
.toString() | ||
.at(0), | ||
tags.value("msg-param-recipient-display-name") | ||
.toString()); | ||
} | ||
} | ||
} | ||
|
||
auto b = MessageBuilder(systemMessage, parseTagString(messageText), | ||
calculateMessageTime(message).time()); | ||
|
@@ -1010,6 +1033,27 @@ 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) | ||
{ | ||
messageText = | ||
QString("An anonymous user gifted %1 months of a Tier " | ||
"%2 sub to %3!") | ||
.arg(QString::number(months), | ||
tags.value("msg-param-sub-plan") | ||
.toString() | ||
.at(0), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can throw if |
||
tags.value("msg-param-recipient-display-name") | ||
.toString()); | ||
} | ||
} | ||
} | ||
|
||
auto b = MessageBuilder(systemMessage, parseTagString(messageText), | ||
calculateMessageTime(message).time()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can throw if
msg-param-sub-plan
is set, but is an empty string.See how SubtierPredicate.cpp does it https://github.com/Chatterino/chatterino2/blob/master/src/messages/search/SubtierPredicate.cpp#L25-L26