From a3f048191aef665f8ffeb7f40fb013518eb60bc8 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:47:14 -0400 Subject: [PATCH 1/4] Recognize continuing anonymous gifts separately from continuing regular gifts --- TwitchDownloaderCore/Tools/HighlightIcons.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/TwitchDownloaderCore/Tools/HighlightIcons.cs b/TwitchDownloaderCore/Tools/HighlightIcons.cs index 1a986769..8e66cde1 100644 --- a/TwitchDownloaderCore/Tools/HighlightIcons.cs +++ b/TwitchDownloaderCore/Tools/HighlightIcons.cs @@ -17,6 +17,7 @@ public enum HighlightType GiftedMany, GiftedSingle, ContinuingGift, + ContinuingAnonymousGift, GiftedAnonymous, PayingForward, ChannelPointHighlight, @@ -104,8 +105,13 @@ public static HighlightType GetHighlightType(Comment comment) if (bodyWithoutName.StartsWith(" gifted a Tier")) return HighlightType.GiftedSingle; - if (bodyWithoutName.StartsWith(" is continuing the Gift Sub")) + if (bodyWithoutName.StartsWith(" is continuing the Gift Sub they got from")) + { + if (bodyWithoutName.EndsWith("from an anonymous user! ")) + return HighlightType.ContinuingAnonymousGift; + return HighlightType.ContinuingGift; + } if (bodyWithoutName.StartsWith(" is paying forward the Gift they got from")) return HighlightType.PayingForward; @@ -162,7 +168,7 @@ public SKImage GetHighlightIcon(HighlightType highlightType, SKColor textColor) HighlightType.SubscribedPrime => _subscribedPrimeIcon ??= GenerateSvgIcon(SUBSCRIBED_PRIME_ICON_SVG, _purple), HighlightType.GiftedSingle => _giftSingleIcon ??= GenerateSvgIcon(GIFTED_SINGLE_ICON_SVG, textColor), HighlightType.GiftedMany => _giftManyIcon ??= GenerateGiftedManyIcon(), - HighlightType.GiftedAnonymous => _giftAnonymousIcon ??= GenerateSvgIcon(GIFTED_ANONYMOUS_ICON_SVG, textColor), + HighlightType.GiftedAnonymous or HighlightType.ContinuingAnonymousGift => _giftAnonymousIcon ??= GenerateSvgIcon(GIFTED_ANONYMOUS_ICON_SVG, textColor), HighlightType.BitBadgeTierNotification => _bitBadgeTierNotificationIcon ??= GenerateSvgIcon(BIT_BADGE_TIER_NOTIFICATION_ICON_SVG, textColor), HighlightType.WatchStreak => _watchStreakIcon ??= GenerateSvgIcon(WATCH_STREAK_ICON_SVG, textColor), HighlightType.CharityDonation => _charityDonationIcon ??= GenerateSvgIcon(CHARITY_DONATION_ICON_SVG, textColor), From 5c3b084d947b2dc89759a7fa0e06d472790eadb7 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:48:08 -0400 Subject: [PATCH 2/4] Update tests --- TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs b/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs index c47ccd45..eb073268 100644 --- a/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs +++ b/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs @@ -98,8 +98,12 @@ private static Comment CreateCommentWithMessage(string viewerDisplayName, string // Special case, in separate method. // ContinuingGift [InlineData( - "{\"body\":\"viewer8 is continuing the Gift Sub they got from an anonymous user! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"viewer8 is continuing the Gift Sub they got from an anonymous user! \",\"emoticon\":null}],\"user_badges\":[{\"_id\":\"subscriber\",\"version\":\"0\"}],\"user_color\":\"#8A2BE2\",\"emoticons\":[]}", + "{\"body\":\"viewer8 is continuing the Gift Sub they got from viewer9! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"viewer8 is continuing the Gift Sub they got from viewer9! \",\"emoticon\":null}],\"user_badges\":[{\"_id\":\"subscriber\",\"version\":\"0\"}],\"user_color\":\"#8A2BE2\",\"emoticons\":[]}", HighlightType.ContinuingGift)] + // ContinuingGift + [InlineData( + "{\"body\":\"viewer8 is continuing the Gift Sub they got from an anonymous user! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"viewer8 is continuing the Gift Sub they got from an anonymous user! \",\"emoticon\":null}],\"user_badges\":[{\"_id\":\"subscriber\",\"version\":\"0\"}],\"user_color\":\"#8A2BE2\",\"emoticons\":[]}", + HighlightType.ContinuingAnonymousGift)] // PayingForward [InlineData( "{\"body\":\"viewer8 is paying forward the Gift they got from an anonymous gifter to the community! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"viewer8 is paying forward the Gift they got from an anonymous gifter to the community! \",\"emoticon\":null}],\"user_badges\":[{\"_id\":\"subscriber\",\"version\":\"0\"},{\"_id\":\"bits\",\"version\":\"100\"}],\"user_color\":null,\"emoticons\":[]}", From d46e52a31277140e4112f4e473702cf34673252c Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:48:36 -0400 Subject: [PATCH 3/4] Render continuing anonymous gift subs correctly --- TwitchDownloaderCore/ChatRenderer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/TwitchDownloaderCore/ChatRenderer.cs b/TwitchDownloaderCore/ChatRenderer.cs index 17861d91..9d8081e8 100644 --- a/TwitchDownloaderCore/ChatRenderer.cs +++ b/TwitchDownloaderCore/ChatRenderer.cs @@ -709,6 +709,7 @@ private void DrawAccentedMessage(Comment comment, List<(SKImageInfo info, SKBitm case HighlightType.GiftedMany: case HighlightType.GiftedSingle: case HighlightType.GiftedAnonymous: + case HighlightType.ContinuingAnonymousGift: DrawGiftMessage(comment, sectionImages, emotePositionList, ref drawPos, defaultPos, highlightIcon, iconPoint); break; case HighlightType.ChannelPointHighlight: From 9250b850f3d13b4e834f2753ecf9771a2b9df8bf Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:49:25 -0400 Subject: [PATCH 4/4] Fix comment --- TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs b/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs index eb073268..1cd6f80b 100644 --- a/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs +++ b/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs @@ -100,7 +100,7 @@ private static Comment CreateCommentWithMessage(string viewerDisplayName, string [InlineData( "{\"body\":\"viewer8 is continuing the Gift Sub they got from viewer9! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"viewer8 is continuing the Gift Sub they got from viewer9! \",\"emoticon\":null}],\"user_badges\":[{\"_id\":\"subscriber\",\"version\":\"0\"}],\"user_color\":\"#8A2BE2\",\"emoticons\":[]}", HighlightType.ContinuingGift)] - // ContinuingGift + // ContinuingAnonymousGift [InlineData( "{\"body\":\"viewer8 is continuing the Gift Sub they got from an anonymous user! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"viewer8 is continuing the Gift Sub they got from an anonymous user! \",\"emoticon\":null}],\"user_badges\":[{\"_id\":\"subscriber\",\"version\":\"0\"}],\"user_color\":\"#8A2BE2\",\"emoticons\":[]}", HighlightType.ContinuingAnonymousGift)]