From 87a84c50a58a97708a7c56d4abe3d33b49d7d6bb Mon Sep 17 00:00:00 2001 From: Scrub <72096833+ScrubN@users.noreply.github.com> Date: Thu, 26 Dec 2024 00:02:55 -0500 Subject: [PATCH] Add Valorant account to bonus gift sub detection (#1273) * Add Valorant account ID to bonus gift sub detection * Update tests --- TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs | 6 +++++- TwitchDownloaderCore/Tools/HighlightIcons.cs | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs b/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs index 95ddaf9b..71d6eba8 100644 --- a/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs +++ b/TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs @@ -159,7 +159,11 @@ public void CorrectlyIdentifiesHighlightTypes(string messageString, HighlightTyp "{\"body\":\"We added 13 Gift Subs AND 10 Bonus Gift Subs to viewer8's gift! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"We added 13 Gift Subs AND 10 Bonus Gift Subs to viewer8's gift! \",\"emoticon\":null}],\"user_badges\":[],\"user_color\":null,\"emoticons\":[]}")] [InlineData("{\"display_name\":\"Twitch\",\"_id\":\"12826\",\"name\":\"twitch\",\"bio\":\"Twitch is where thousands of communities come together for whatever, every day. \",\"created_at\":\"2007-05-22T10:39:54.238271Z\",\"updated_at\":\"2024-09-22T22:28:39.594659Z\",\"logo\":\"https://static-cdn.jtvnw.net/jtv_user_pictures/aa88230d-7af5-4053-a7cd-889e626d3382-profile_image-300x300.png\"}", "{\"body\":\"We added 1 Gift Subs to viewer8's gift! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"We added 1 Gift Subs to viewer8's gift! \",\"emoticon\":null}],\"user_badges\":[],\"user_color\":null,\"emoticons\":[]}")] - public void CorrectlyIdentifiesSubtemberGiftedMany(string commenterString, string messageString) + [InlineData("{\"display_name\": \"VALORANT\",\"_id\": \"490592527\",\"name\": \"valorant\",\"bio\": \"VALORANT is a 5v5 character based tactical shooter video game from Riot Games. \",\"created_at\": \"2007-05-22T10:39:54.238271Z\",\"updated_at\": \"2024-09-22T22:28:39.594659Z\",\"logo\": \"https://static-cdn.jtvnw.net/jtv_user_pictures/34c5c8da-19b6-47b2-85ba-cc7ae87f1413-profile_image-300x300.png\"}", + "{\"body\":\"We added 13 Gift Subs AND 10 Bonus Gift Subs to viewer8's gift! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"We added 13 Gift Subs AND 10 Bonus Gift Subs to viewer8's gift! \",\"emoticon\":null}],\"user_badges\":[],\"user_color\":null,\"emoticons\":[]}")] + [InlineData("{\"display_name\": \"VALORANT\",\"_id\": \"490592527\",\"name\": \"valorant\",\"bio\": \"VALORANT is a 5v5 character based tactical shooter video game from Riot Games. \",\"created_at\": \"2007-05-22T10:39:54.238271Z\",\"updated_at\": \"2024-09-22T22:28:39.594659Z\",\"logo\": \"https://static-cdn.jtvnw.net/jtv_user_pictures/34c5c8da-19b6-47b2-85ba-cc7ae87f1413-profile_image-300x300.png\"}", + "{\"body\":\"We added 1 Gift Subs to viewer8's gift! \",\"bits_spent\":0,\"fragments\":[{\"text\":\"We added 1 Gift Subs to viewer8's gift! \",\"emoticon\":null}],\"user_badges\":[],\"user_color\":null,\"emoticons\":[]}")] + public void CorrectlyIdentifiesBonusSubsGiftedMany(string commenterString, string messageString) { const HighlightType EXPECTED_TYPE = HighlightType.GiftedMany; diff --git a/TwitchDownloaderCore/Tools/HighlightIcons.cs b/TwitchDownloaderCore/Tools/HighlightIcons.cs index b9b501ae..6fb611a4 100644 --- a/TwitchDownloaderCore/Tools/HighlightIcons.cs +++ b/TwitchDownloaderCore/Tools/HighlightIcons.cs @@ -160,10 +160,11 @@ public static HighlightType GetHighlightType(Comment comment) if (comment.commenter._id is ANONYMOUS_GIFT_ACCOUNT_ID or TWITCH_ACCOUNT_ID && GiftAnonymousRegex.IsMatch(comment.message.body)) return HighlightType.GiftedAnonymous; - if (comment.commenter._id is TWITCH_ACCOUNT_ID && comment.message.body.EndsWith("'s gift! ") && + const string VALORANT_ACCOUNT_ID = "490592527"; + if (comment.commenter._id is TWITCH_ACCOUNT_ID or VALORANT_ACCOUNT_ID && comment.message.body.EndsWith("'s gift! ") && Regex.IsMatch(comment.message.body, @"^We added \d+ Gift Subs (?:AND \d+ Bonus Gift Subs )?to ")) { - // TODO: Make a dedicated enum value for Subtember? + // TODO: Make a dedicated enum value for bonus gift subs? return HighlightType.GiftedMany; }