Skip to content
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

Add Valorant account to bonus gift sub detection #1273

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion TwitchDownloaderCore.Tests/ToolTests/HighlightIconsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions TwitchDownloaderCore/Tools/HighlightIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading