Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into chatterino7
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Apr 2, 2024
2 parents c381a2c + 8db0bb4 commit 3d00ac7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- Minor: Add `reward.cost` `reward.id`, `reward.title` filter variables. (#5275)
- Minor: Change Lua `CompletionRequested` handler to use an event table. (#5280)
- Minor: Changed the layout of the about page. (#5287)
- Minor: Add duration to multi-month anon sub gift messages. (#5293)
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
- Bugfix: Fixed the `/shoutout` command not working with usernames starting with @'s (e.g. `/shoutout @forsen`). (#4800)
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
Expand Down Expand Up @@ -122,6 +123,7 @@
- Bugfix: Truncated IRC messages to be at most 512 bytes. (#5246)
- Bugfix: Fixed a data race when disconnecting from Twitch PubSub. (#4771)
- Bugfix: Fixed messages not immediately disappearing when clearing the chat. (#5282)
- Bugfix: Fixed highlights triggering for ignored users in announcements. (#5295)
- Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978)
- Dev: Change clang-format from v14 to v16. (#4929)
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
Expand Down
4 changes: 2 additions & 2 deletions src/messages/SharedMessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ void SharedMessageBuilder::parseUsername()

void SharedMessageBuilder::parseHighlights()
{
if (getSettings()->isBlacklistedUser(this->ircMessage->nick()))
if (getSettings()->isBlacklistedUser(this->message().loginName))
{
// Do nothing. We ignore highlights from this user.
return;
}

auto badges = SharedMessageBuilder::parseBadgeTag(this->tags);
auto [highlighted, highlightResult] = getIApp()->getHighlights()->check(
this->args, badges, this->ircMessage->nick(), this->originalMessage_,
this->args, badges, this->message().loginName, this->originalMessage_,
this->message().flags);

if (!highlighted)
Expand Down
42 changes: 42 additions & 0 deletions src/providers/twitch/IrcMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
6 changes: 6 additions & 0 deletions src/util/SampleData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ const QStringList &getSampleSubMessages()
// hyperbolicxd gifted a sub to quote_if_nam
R"(@badges=subscriber/0,premium/1;color=#00FF7F;display-name=hyperbolicxd;emotes=;id=b20ef4fe-cba8-41d0-a371-6327651dc9cc;login=hyperbolicxd;mod=0;msg-id=subgift;msg-param-months=1;msg-param-recipient-display-name=quote_if_nam;msg-param-recipient-id=217259245;msg-param-recipient-user-name=quote_if_nam;msg-param-sender-count=1;msg-param-sub-plan-name=Channel\sSubscription\s(nymn_hs);msg-param-sub-plan=1000;room-id=62300805;subscriber=1;system-msg=hyperbolicxd\sgifted\sa\sTier\s1\ssub\sto\squote_if_nam!\sThis\sis\stheir\sfirst\sGift\sSub\sin\sthe\schannel!;tmi-sent-ts=1528190938558;turbo=0;user-id=111534250;user-type= :tmi.twitch.tv USERNOTICE #pajlada)",

// multi-month sub gift
R"(@badge-info=subscriber/32;badges=subscriber/3030,sub-gift-leader/2;color=#FF8EA3;display-name=iNatsuFN;emotes=;flags=;id=0d0decbd-b8f4-4e83-9e18-eca9cab69153;login=inatsufn;mod=0;msg-id=subgift;msg-param-gift-months=6;msg-param-goal-contribution-type=SUBS;msg-param-goal-current-contributions=881;msg-param-goal-target-contributions=900;msg-param-goal-user-contributions=1;msg-param-months=16;msg-param-origin-id=2524053421157386961;msg-param-recipient-display-name=kimmi_tm;msg-param-recipient-id=225806893;msg-param-recipient-user-name=kimmi_tm;msg-param-sender-count=334;msg-param-sub-plan-name=Channel\sSubscription\s(mxddy);msg-param-sub-plan=1000;room-id=210915729;subscriber=1;system-msg=iNatsuFN\sgifted\s6\smonths\sof\sTier\s1\sto\skimmi_tm.\sThey've\sgifted\s334\smonths\sin\sthe\schannel!;tmi-sent-ts=1712034497332;user-id=218205938;user-type=;vip=0 :tmi.twitch.tv USERNOTICE #mxddy)",

// multi-month anon sub gift
R"(@msg-param-goal-user-contributions=1;system-msg=An\sanonymous\suser\sgifted\sa\sTier\s1\ssub\sto\sMohammadrezaDH!\s;msg-param-goal-current-contributions=2;vip=0;color=;user-id=274598607;mod=0;flags=;msg-param-months=2;historical=1;id=afa2155b-f563-4973-a5c2-e4075882bbfb;msg-param-gift-months=6;msg-id=subgift;badge-info=;msg-param-recipient-user-name=mohammadrezadh;login=ananonymousgifter;room-id=441388138;msg-param-goal-target-contributions=25;rm-received-ts=1712002037736;msg-param-recipient-id=204174899;emotes=;display-name=AnAnonymousGifter;badges=;msg-param-fun-string=FunStringFive;msg-param-goal-contribution-type=NEW_SUB_POINTS;msg-param-origin-id=8862142563198473546;msg-param-recipient-display-name=MohammadrezaDH;msg-param-sub-plan-name=jmarxists;user-type=;subscriber=0;tmi-sent-ts=1712002037615;msg-param-sub-plan=1000;msg-param-goal-description=day\slee\sgoal\s:-) :tmi.twitch.tv USERNOTICE #jmarianne)",

// first time sub
R"(@badges=subscriber/0,premium/1;color=#0000FF;display-name=byebyeheart;emotes=;id=fe390424-ab89-4c33-bb5a-53c6e5214b9f;login=byebyeheart;mod=0;msg-id=sub;msg-param-months=0;msg-param-sub-plan-name=Dakotaz;msg-param-sub-plan=Prime;room-id=39298218;subscriber=0;system-msg=byebyeheart\sjust\ssubscribed\swith\sTwitch\sPrime!;tmi-sent-ts=1528190963670;turbo=0;user-id=131956000;user-type= :tmi.twitch.tv USERNOTICE #pajlada)",

Expand Down

0 comments on commit 3d00ac7

Please sign in to comment.