diff --git a/CHANGELOG.md b/CHANGELOG.md index 560e533..cbe1592 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Version numbers follow [Semantic Versioning](https://semver.org/). applies to the `client_secret` in `RefreshingLoginCredentials`. (#199) - Minor: Added example demonstrating usage of `metrics-collection` feature as well as an exemplary grafana dashboard template. (#203, #208) +- Minor: Fixed missing tag durring SUBtember (#215) ## v5.0.1 diff --git a/src/message/commands/usernotice.rs b/src/message/commands/usernotice.rs index c711f95..2e0628c 100644 --- a/src/message/commands/usernotice.rs +++ b/src/message/commands/usernotice.rs @@ -424,7 +424,14 @@ impl TryFrom for UserNoticeMessage { // this takes over all other cases of submysterygift. "submysterygift" => UserNoticeEvent::SubMysteryGift { mass_gift_count: source.try_get_number("msg-param-mass-gift-count")?, - sender_total_gifts: source.try_get_number("msg-param-sender-count")?, + sender_total_gifts: if sender.login != "twitch" { + source.try_get_number("msg-param-sender-count")? + } else { + // - this seems to be missing if sender the sender is twitch (user-id=12826) on subtembers + source + .try_get_number("msg-param-sender-count") + .unwrap_or(std::u64::MAX) // unlimited gifts + }, sub_plan: source .try_get_nonempty_tag_value("msg-param-sub-plan")? .to_owned(), @@ -781,6 +788,38 @@ mod tests { ) } + #[test] + pub fn test_submysterygift_twitch() { + let src = "@badge-info=;badges=sub-gifter/50;color=;display-name=twitch;emotes=;flags=;id=049e6371-7023-4fca-8605-7dec60e72e12;login=twitch;mod=0;msg-id=submysterygift;msg-param-mass-gift-count=20;msg-param-sender-count=50;msg-param-origin-id=1f\\sbe\\sbb\\s4a\\s81\\s9a\\s65\\sd1\\s4b\\s77\\sf5\\s23\\s16\\s4a\\sd3\\s13\\s09\\se7\\sbe\\s55;msg-param-sub-plan=1000;room-id=71092938;subscriber=0;system-msg=AdamAtReflectStudios\\sis\\sgifting\\s20\\sTier\\s1\\sSubs\\sto\\sxQcOW's\\scommunity!\\sThey've\\sgifted\\sa\\stotal\\sof\\s100\\sin\\sthe\\schannel!;tmi-sent-ts=1594583777669;user-id=12826;user-type= :tmi.twitch.tv USERNOTICE #xqcow"; + let irc_message = IRCMessage::parse(src).unwrap(); + let msg = UserNoticeMessage::try_from(irc_message).unwrap(); + + assert_eq!( + msg.event, + UserNoticeEvent::SubMysteryGift { + mass_gift_count: 20, + sender_total_gifts: 50, + sub_plan: "1000".to_owned(), + } + ) + } + + #[test] + pub fn test_submysterygift_twitch_missing_count() { + let src = "@badge-info=;badges=sub-gifter/50;color=;display-name=twitch;emotes=;flags=;id=049e6371-7023-4fca-8605-7dec60e72e12;login=twitch;mod=0;msg-id=submysterygift;msg-param-mass-gift-count=20;msg-param-origin-id=1f\\sbe\\sbb\\s4a\\s81\\s9a\\s65\\sd1\\s4b\\s77\\sf5\\s23\\s16\\s4a\\sd3\\s13\\s09\\se7\\sbe\\s55;msg-param-sub-plan=1000;room-id=71092938;subscriber=0;system-msg=AdamAtReflectStudios\\sis\\sgifting\\s20\\sTier\\s1\\sSubs\\sto\\sxQcOW's\\scommunity!\\sThey've\\sgifted\\sa\\stotal\\sof\\s100\\sin\\sthe\\schannel!;tmi-sent-ts=1594583777669;user-id=12826;user-type= :tmi.twitch.tv USERNOTICE #xqcow"; + let irc_message = IRCMessage::parse(src).unwrap(); + let msg = UserNoticeMessage::try_from(irc_message).unwrap(); + + assert_eq!( + msg.event, + UserNoticeEvent::SubMysteryGift { + mass_gift_count: 20, + sender_total_gifts: std::u64::MAX, + sub_plan: "1000".to_owned(), + } + ) + } + #[test] pub fn test_submysterygift_ananonymousgifter() { let src = "@badge-info=;badges=;color=;display-name=AnAnonymousGifter;emotes=;flags=;id=8db97752-3dee-460b-9001-e925d0e2ba5b;login=ananonymousgifter;mod=0;msg-id=submysterygift;msg-param-mass-gift-count=10;msg-param-origin-id=13\\s33\\sed\\sc0\\sef\\sa0\\s7b\\s9b\\s48\\s59\\scb\\scc\\se4\\s39\\s7b\\s90\\sf9\\s54\\s75\\s66;msg-param-sub-plan=1000;room-id=71092938;subscriber=0;system-msg=An\\sanonymous\\suser\\sis\\sgifting\\s10\\sTier\\s1\\sSubs\\sto\\sxQcOW's\\scommunity!;tmi-sent-ts=1585447099603;user-id=274598607;user-type= :tmi.twitch.tv USERNOTICE #xqcow";