From 8950236d64bda87fd11ad7289776fa5b0f19e78c Mon Sep 17 00:00:00 2001 From: nerix Date: Mon, 17 Mar 2025 14:33:36 +0100 Subject: [PATCH] fix(eventsub): stack bans (#6092) --- CHANGELOG.md | 2 +- .../twitch/eventsub/MessageBuilder.cpp | 34 -- .../twitch/eventsub/MessageBuilder.hpp | 5 - .../twitch/eventsub/MessageHandlers.cpp | 49 ++- .../twitch/eventsub/MessageHandlers.hpp | 7 + .../EventSub/channel-moderate/ban-reason.json | 2 +- .../channel-moderate/ban-stacking-reason.json | 365 ++++++++++++++++ .../channel-moderate/ban-stacking.json | 347 +++++++++++++++ .../EventSub/channel-moderate/ban.json | 2 +- .../channel-moderate/shared-ban-reason.json | 4 +- .../shared-ban-stacking-diff-sources.json | 410 ++++++++++++++++++ .../channel-moderate/shared-ban-stacking.json | 263 +++++++++++ .../EventSub/channel-moderate/shared-ban.json | 4 +- 13 files changed, 1446 insertions(+), 48 deletions(-) create mode 100644 tests/snapshots/EventSub/channel-moderate/ban-stacking-reason.json create mode 100644 tests/snapshots/EventSub/channel-moderate/ban-stacking.json create mode 100644 tests/snapshots/EventSub/channel-moderate/shared-ban-stacking-diff-sources.json create mode 100644 tests/snapshots/EventSub/channel-moderate/shared-ban-stacking.json diff --git a/CHANGELOG.md b/CHANGELOG.md index ea5471c6..c172baf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ - Bugfix: Fixed some windows not immediately closing. (#6054) - Bugfix: The emote button no longer looks crunchy. (#6080, #6085) - Dev: Subscriptions to PubSub channel points redemption topics now use no auth token, making it continue to work during PubSub shutdown. (#5947) -- Dev: Add initial experimental EventSub support. (#5837, #5895, #5897, #5904, #5910, #5903, #5915, #5916, #5930, #5935, #5932, #5943, #5952, #5953, #5968, #5973, #5974, #5980, #5981, #5985, #5990, #5992, #5993, #5996, #5995, #6000, #6001, #6002, #6003, #6005, #6007, #6010, #6008, #6012, #6013, #6015, #6017, #6027, #6028, #6035, #6036, #6040, #6041, #6048, #6058, #6059, #6078, #6079, #6086) +- Dev: Add initial experimental EventSub support. (#5837, #5895, #5897, #5904, #5910, #5903, #5915, #5916, #5930, #5935, #5932, #5943, #5952, #5953, #5968, #5973, #5974, #5980, #5981, #5985, #5990, #5992, #5993, #5996, #5995, #6000, #6001, #6002, #6003, #6005, #6007, #6010, #6008, #6012, #6013, #6015, #6017, #6027, #6028, #6035, #6036, #6040, #6041, #6048, #6058, #6059, #6078, #6079, #6086, #6092) - Dev: Remove unneeded platform specifier for toasts. (#5914) - Dev: Cleanly shutdown on `SIGINT`/`SIGTERM` on Linux & macOS. (#6053) - Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784) diff --git a/src/providers/twitch/eventsub/MessageBuilder.cpp b/src/providers/twitch/eventsub/MessageBuilder.cpp index 5f900fb4..8aab04dc 100644 --- a/src/providers/twitch/eventsub/MessageBuilder.cpp +++ b/src/providers/twitch/eventsub/MessageBuilder.cpp @@ -251,40 +251,6 @@ void makeModerateMessage(EventSubMessageBuilder &builder, builder.setMessageAndSearchText(text); } -void makeModerateMessage(EventSubMessageBuilder &builder, - const lib::payload::channel_moderate::v2::Event &event, - const lib::payload::channel_moderate::v2::Ban &action) -{ - builder->flags.set(MessageFlag::ModerationAction, MessageFlag::Timeout); - - QString text; - bool isShared = event.isFromSharedChat(); - - builder.appendUser(event.moderatorUserName, event.moderatorUserLogin, text); - builder.emplaceSystemTextAndUpdate("banned", text); - builder.appendUser(action.userName, action.userLogin, text, isShared); - - if (isShared) - { - builder.emplaceSystemTextAndUpdate("in", text); - builder.appendUser(*event.sourceBroadcasterUserName, - *event.sourceBroadcasterUserLogin, text, false); - } - - if (action.reason.view().empty()) - { - builder.emplaceSystemTextAndUpdate(".", text); - } - else - { - builder.emplaceSystemTextAndUpdate(":", text); - builder.emplaceSystemTextAndUpdate(action.reason.qt(), text); - } - - builder.setMessageAndSearchText(text); - builder->timeoutUser = action.userLogin.qt(); -} - void makeModerateMessage( EventSubMessageBuilder &builder, const lib::payload::channel_moderate::v2::Event &event, diff --git a/src/providers/twitch/eventsub/MessageBuilder.hpp b/src/providers/twitch/eventsub/MessageBuilder.hpp index bc3cb36e..d8d8e0cd 100644 --- a/src/providers/twitch/eventsub/MessageBuilder.hpp +++ b/src/providers/twitch/eventsub/MessageBuilder.hpp @@ -61,11 +61,6 @@ void makeModerateMessage( const lib::payload::channel_moderate::v2::Event &event, const lib::payload::channel_moderate::v2::Warn &action); -/// banned [ in ]: -void makeModerateMessage(EventSubMessageBuilder &builder, - const lib::payload::channel_moderate::v2::Event &event, - const lib::payload::channel_moderate::v2::Ban &action); - /// unbanned [ in ]. void makeModerateMessage( EventSubMessageBuilder &builder, diff --git a/src/providers/twitch/eventsub/MessageHandlers.cpp b/src/providers/twitch/eventsub/MessageHandlers.cpp index d0803588..121f538e 100644 --- a/src/providers/twitch/eventsub/MessageHandlers.cpp +++ b/src/providers/twitch/eventsub/MessageHandlers.cpp @@ -92,8 +92,53 @@ void handleModerateMessage( builder.emplaceSystemTextAndUpdate(action.reason.qt(), text); } - builder->messageText = text; - builder->searchText = text; + builder.setMessageAndSearchText(text); + builder->timeoutUser = action.userLogin.qt(); + + auto msg = builder.release(); + runInGuiThread([chan, msg, time] { + chan->addOrReplaceTimeout(msg, time); + }); +} + +void handleModerateMessage( + TwitchChannel *chan, const QDateTime &time, + const lib::payload::channel_moderate::v2::Event &event, + const lib::payload::channel_moderate::v2::Ban &action) +{ + EventSubMessageBuilder builder(chan, time); + builder->loginName = event.moderatorUserLogin.qt(); + // pretend we're pubsub + builder->flags.set(MessageFlag::PubSub, MessageFlag::Timeout, + MessageFlag::ModerationAction); + + QString text; + bool isShared = event.isFromSharedChat(); + + builder.appendUser(event.moderatorUserName, event.moderatorUserLogin, text); + builder.emplaceSystemTextAndUpdate("banned", text); + builder.appendUser(action.userName, action.userLogin, text, isShared); + + if (isShared) + { + builder.emplaceSystemTextAndUpdate("in", text); + builder.appendUser(*event.sourceBroadcasterUserName, + *event.sourceBroadcasterUserLogin, text, false); + builder->flags.set(MessageFlag::SharedMessage); + builder->channelName = event.sourceBroadcasterUserLogin->qt(); + } + + if (action.reason.view().empty()) + { + builder.emplaceSystemTextAndUpdate(".", text); + } + else + { + builder.emplaceSystemTextAndUpdate(":", text); + builder.emplaceSystemTextAndUpdate(action.reason.qt(), text); + } + + builder.setMessageAndSearchText(text); builder->timeoutUser = action.userLogin.qt(); auto msg = builder.release(); diff --git a/src/providers/twitch/eventsub/MessageHandlers.hpp b/src/providers/twitch/eventsub/MessageHandlers.hpp index e4fc84df..1d4dd15f 100644 --- a/src/providers/twitch/eventsub/MessageHandlers.hpp +++ b/src/providers/twitch/eventsub/MessageHandlers.hpp @@ -22,9 +22,16 @@ void handleModerateMessage( const lib::payload::channel_moderate::v2::Event &event, const lib::payload::channel_moderate::v2::Clear &action); +/// timed out for [ in ]: void handleModerateMessage( TwitchChannel *chan, const QDateTime &time, const lib::payload::channel_moderate::v2::Event &event, const lib::payload::channel_moderate::v2::Timeout &action); +/// banned [ in ]: +void handleModerateMessage( + TwitchChannel *chan, const QDateTime &time, + const lib::payload::channel_moderate::v2::Event &event, + const lib::payload::channel_moderate::v2::Ban &action); + } // namespace chatterino::eventsub diff --git a/tests/snapshots/EventSub/channel-moderate/ban-reason.json b/tests/snapshots/EventSub/channel-moderate/ban-reason.json index 465a1ac4..1d09e7a7 100644 --- a/tests/snapshots/EventSub/channel-moderate/ban-reason.json +++ b/tests/snapshots/EventSub/channel-moderate/ban-reason.json @@ -157,7 +157,7 @@ ] } ], - "flags": "System|Timeout|EventSub|ModerationAction", + "flags": "System|Timeout|PubSub|EventSub|ModerationAction", "id": "", "localizedName": "", "loginName": "nerixyz", diff --git a/tests/snapshots/EventSub/channel-moderate/ban-stacking-reason.json b/tests/snapshots/EventSub/channel-moderate/ban-stacking-reason.json new file mode 100644 index 00000000..f3731f6e --- /dev/null +++ b/tests/snapshots/EventSub/channel-moderate/ban-stacking-reason.json @@ -0,0 +1,365 @@ +{ + "input": [ + { + "__timestamp": "2025-02-22T17:53:49.800959069Z", + "action": "ban", + "automod_terms": null, + "ban": { + "reason": "my reason", + "user_id": "489584266", + "user_login": "uint128", + "user_name": "uint128" + }, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": null, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": null, + "source_broadcaster_user_login": null, + "source_broadcaster_user_name": null, + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + }, + { + "__timestamp": "2025-02-22T17:53:50.800959069Z", + "action": "ban", + "automod_terms": null, + "ban": { + "reason": "my reason", + "user_id": "489584266", + "user_login": "uint128", + "user_name": "uint128" + }, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": null, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": null, + "source_broadcaster_user_login": null, + "source_broadcaster_user_name": null, + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + }, + { + "__timestamp": "2025-02-22T17:54:50.800959069Z", + "action": "ban", + "automod_terms": null, + "ban": { + "reason": "my reason", + "user_id": "489584266", + "user_login": "uint128", + "user_name": "uint128" + }, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": null, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": null, + "source_broadcaster_user_login": null, + "source_broadcaster_user_name": null, + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + } + ], + "output": [ + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "", + "count": 2, + "displayName": "", + "elements": [ + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "TimestampMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "17:53" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "17:53:50", + "tooltip": "", + "trailingSpace": true, + "type": "TimestampElement" + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "nerixyz" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "nerixyz" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "banned" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "uint128" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": false, + "type": "TextElement", + "words": [ + "uint128" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + ":", + "my", + "reason", + "(2", + "times)" + ] + } + ], + "flags": "System|Timeout|PubSub|EventSub|ModerationAction", + "id": "", + "localizedName": "", + "loginName": "", + "messageText": "nerixyz banned uint128: my reason (2 times) ", + "searchText": "nerixyz banned uint128: my reason (2 times) ", + "serverReceivedTime": "2025-02-22T17:53:50Z", + "timeoutUser": "uint128", + "userID": "", + "usernameColor": "#ff000000" + }, + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "", + "count": 1, + "displayName": "", + "elements": [ + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "TimestampMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "17:54" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "17:54:50", + "tooltip": "", + "trailingSpace": true, + "type": "TimestampElement" + }, + { + "color": "Text", + "fallbackColor": "System", + "flags": "Text|Mention", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "MentionElement", + "userColor": "System", + "userLoginName": "nerixyz", + "words": [ + "nerixyz" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "banned" + ] + }, + { + "color": "Text", + "fallbackColor": "System", + "flags": "Text|Mention", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": false, + "type": "MentionElement", + "userColor": "System", + "userLoginName": "uint128", + "words": [ + "uint128" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + ":" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "my", + "reason" + ] + } + ], + "flags": "System|Timeout|PubSub|EventSub|ModerationAction", + "id": "", + "localizedName": "", + "loginName": "nerixyz", + "messageText": "nerixyz banned uint128: my reason ", + "searchText": "nerixyz banned uint128: my reason ", + "serverReceivedTime": "2025-02-22T17:54:50Z", + "timeoutUser": "uint128", + "userID": "", + "usernameColor": "#ff000000" + } + ] +} diff --git a/tests/snapshots/EventSub/channel-moderate/ban-stacking.json b/tests/snapshots/EventSub/channel-moderate/ban-stacking.json new file mode 100644 index 00000000..1bf3a107 --- /dev/null +++ b/tests/snapshots/EventSub/channel-moderate/ban-stacking.json @@ -0,0 +1,347 @@ +{ + "input": [ + { + "__timestamp": "2025-02-22T17:53:49.800959069Z", + "action": "ban", + "automod_terms": null, + "ban": { + "reason": "", + "user_id": "489584266", + "user_login": "uint128", + "user_name": "uint128" + }, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": null, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": null, + "source_broadcaster_user_login": null, + "source_broadcaster_user_name": null, + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + }, + { + "__timestamp": "2025-02-22T17:53:50.800959069Z", + "action": "ban", + "automod_terms": null, + "ban": { + "reason": "", + "user_id": "489584266", + "user_login": "uint128", + "user_name": "uint128" + }, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": null, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": null, + "source_broadcaster_user_login": null, + "source_broadcaster_user_name": null, + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + }, + { + "__timestamp": "2025-02-22T17:54:50.800959069Z", + "action": "ban", + "automod_terms": null, + "ban": { + "reason": "", + "user_id": "489584266", + "user_login": "uint128", + "user_name": "uint128" + }, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": null, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": null, + "source_broadcaster_user_login": null, + "source_broadcaster_user_name": null, + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + } + ], + "output": [ + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "", + "count": 2, + "displayName": "", + "elements": [ + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "TimestampMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "17:53" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "17:53:50", + "tooltip": "", + "trailingSpace": true, + "type": "TimestampElement" + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "nerixyz" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "nerixyz" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "banned" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "uint128" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": false, + "type": "TextElement", + "words": [ + "uint128" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + ".", + "(2", + "times)" + ] + } + ], + "flags": "System|Timeout|PubSub|EventSub|ModerationAction", + "id": "", + "localizedName": "", + "loginName": "", + "messageText": "nerixyz banned uint128. (2 times) ", + "searchText": "nerixyz banned uint128. (2 times) ", + "serverReceivedTime": "2025-02-22T17:53:50Z", + "timeoutUser": "uint128", + "userID": "", + "usernameColor": "#ff000000" + }, + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "", + "count": 1, + "displayName": "", + "elements": [ + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "TimestampMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "17:54" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "17:54:50", + "tooltip": "", + "trailingSpace": true, + "type": "TimestampElement" + }, + { + "color": "Text", + "fallbackColor": "System", + "flags": "Text|Mention", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "MentionElement", + "userColor": "System", + "userLoginName": "nerixyz", + "words": [ + "nerixyz" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "banned" + ] + }, + { + "color": "Text", + "fallbackColor": "System", + "flags": "Text|Mention", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": false, + "type": "MentionElement", + "userColor": "System", + "userLoginName": "uint128", + "words": [ + "uint128" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "." + ] + } + ], + "flags": "System|Timeout|PubSub|EventSub|ModerationAction", + "id": "", + "localizedName": "", + "loginName": "nerixyz", + "messageText": "nerixyz banned uint128. ", + "searchText": "nerixyz banned uint128. ", + "serverReceivedTime": "2025-02-22T17:54:50Z", + "timeoutUser": "uint128", + "userID": "", + "usernameColor": "#ff000000" + } + ] +} diff --git a/tests/snapshots/EventSub/channel-moderate/ban.json b/tests/snapshots/EventSub/channel-moderate/ban.json index 2b77e363..dddeaa1c 100644 --- a/tests/snapshots/EventSub/channel-moderate/ban.json +++ b/tests/snapshots/EventSub/channel-moderate/ban.json @@ -141,7 +141,7 @@ ] } ], - "flags": "System|Timeout|EventSub|ModerationAction", + "flags": "System|Timeout|PubSub|EventSub|ModerationAction", "id": "", "localizedName": "", "loginName": "nerixyz", diff --git a/tests/snapshots/EventSub/channel-moderate/shared-ban-reason.json b/tests/snapshots/EventSub/channel-moderate/shared-ban-reason.json index e815c236..209affde 100644 --- a/tests/snapshots/EventSub/channel-moderate/shared-ban-reason.json +++ b/tests/snapshots/EventSub/channel-moderate/shared-ban-reason.json @@ -43,7 +43,7 @@ }, "badges": [ ], - "channelName": "", + "channelName": "testaccount_420", "count": 1, "displayName": "", "elements": [ @@ -191,7 +191,7 @@ ] } ], - "flags": "System|Timeout|EventSub|ModerationAction", + "flags": "System|Timeout|PubSub|SharedMessage|EventSub|ModerationAction", "id": "", "localizedName": "", "loginName": "nerixyz", diff --git a/tests/snapshots/EventSub/channel-moderate/shared-ban-stacking-diff-sources.json b/tests/snapshots/EventSub/channel-moderate/shared-ban-stacking-diff-sources.json new file mode 100644 index 00000000..fc885427 --- /dev/null +++ b/tests/snapshots/EventSub/channel-moderate/shared-ban-stacking-diff-sources.json @@ -0,0 +1,410 @@ +{ + "input": [ + { + "__timestamp": "2025-02-22T17:54:04.523432776Z", + "action": "shared_chat_ban", + "automod_terms": null, + "ban": null, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": { + "reason": "", + "user_id": "141981764", + "user_login": "twitchdev", + "user_name": "TwitchDev" + }, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": "117166826", + "source_broadcaster_user_login": "testaccount_420", + "source_broadcaster_user_name": "테스트계정420", + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + }, + { + "__timestamp": "2025-02-22T17:54:05.523432776Z", + "action": "shared_chat_ban", + "automod_terms": null, + "ban": null, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": { + "reason": "", + "user_id": "141981764", + "user_login": "twitchdev", + "user_name": "TwitchDev" + }, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": "117166826", + "source_broadcaster_user_login": "testaccount_420", + "source_broadcaster_user_name": "테스트계정420", + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + }, + { + "__timestamp": "2025-02-22T17:54:06.523432776Z", + "action": "shared_chat_ban", + "automod_terms": null, + "ban": null, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": { + "reason": "", + "user_id": "141981764", + "user_login": "twitchdev", + "user_name": "TwitchDev" + }, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": "22484632", + "source_broadcaster_user_login": "forsen", + "source_broadcaster_user_name": "forsen", + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + } + ], + "output": [ + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "testaccount_420", + "count": 2, + "displayName": "", + "elements": [ + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "TimestampMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "17:54" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "17:54:05", + "tooltip": "", + "trailingSpace": true, + "type": "TimestampElement" + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "nerixyz" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "nerixyz" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "banned" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "twitchdev" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "twitchdev" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "in" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "testaccount_420" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": false, + "type": "TextElement", + "words": [ + "testaccount_420" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + ".", + "(2", + "times)" + ] + } + ], + "flags": "System|Timeout|PubSub|SharedMessage|EventSub|ModerationAction", + "id": "", + "localizedName": "", + "loginName": "", + "messageText": "nerixyz banned twitchdev in testaccount_420. (2 times) ", + "searchText": "nerixyz banned twitchdev in testaccount_420. (2 times) ", + "serverReceivedTime": "2025-02-22T17:54:05Z", + "timeoutUser": "twitchdev", + "userID": "", + "usernameColor": "#ff000000" + }, + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "forsen", + "count": 1, + "displayName": "", + "elements": [ + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "TimestampMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "17:54" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "17:54:06", + "tooltip": "", + "trailingSpace": true, + "type": "TimestampElement" + }, + { + "color": "Text", + "fallbackColor": "System", + "flags": "Text|Mention", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "MentionElement", + "userColor": "System", + "userLoginName": "nerixyz", + "words": [ + "nerixyz" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "banned" + ] + }, + { + "color": "Text", + "fallbackColor": "System", + "flags": "Text|Mention", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "MentionElement", + "userColor": "System", + "userLoginName": "twitchdev", + "words": [ + "TwitchDev" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "in" + ] + }, + { + "color": "Text", + "fallbackColor": "System", + "flags": "Text|Mention", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": false, + "type": "MentionElement", + "userColor": "System", + "userLoginName": "forsen", + "words": [ + "forsen" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "." + ] + } + ], + "flags": "System|Timeout|PubSub|SharedMessage|EventSub|ModerationAction", + "id": "", + "localizedName": "", + "loginName": "nerixyz", + "messageText": "nerixyz banned twitchdev in forsen. ", + "searchText": "nerixyz banned twitchdev in forsen. ", + "serverReceivedTime": "2025-02-22T17:54:06Z", + "timeoutUser": "twitchdev", + "userID": "", + "usernameColor": "#ff000000" + } + ] +} diff --git a/tests/snapshots/EventSub/channel-moderate/shared-ban-stacking.json b/tests/snapshots/EventSub/channel-moderate/shared-ban-stacking.json new file mode 100644 index 00000000..8ce07056 --- /dev/null +++ b/tests/snapshots/EventSub/channel-moderate/shared-ban-stacking.json @@ -0,0 +1,263 @@ +{ + "input": [ + { + "__timestamp": "2025-02-22T17:54:04.523432776Z", + "action": "shared_chat_ban", + "automod_terms": null, + "ban": null, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": { + "reason": "", + "user_id": "141981764", + "user_login": "twitchdev", + "user_name": "TwitchDev" + }, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": "117166826", + "source_broadcaster_user_login": "testaccount_420", + "source_broadcaster_user_name": "테스트계정420", + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + }, + { + "__timestamp": "2025-02-22T17:54:05.523432776Z", + "action": "shared_chat_ban", + "automod_terms": null, + "ban": null, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": { + "reason": "", + "user_id": "141981764", + "user_login": "twitchdev", + "user_name": "TwitchDev" + }, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": "117166826", + "source_broadcaster_user_login": "testaccount_420", + "source_broadcaster_user_name": "테스트계정420", + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + }, + { + "__timestamp": "2025-02-22T17:54:06.523432776Z", + "action": "shared_chat_ban", + "automod_terms": null, + "ban": null, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": null, + "moderator_user_id": "129546453", + "moderator_user_login": "nerixyz", + "moderator_user_name": "nerixyz", + "raid": null, + "shared_chat_ban": { + "reason": "", + "user_id": "141981764", + "user_login": "twitchdev", + "user_name": "TwitchDev" + }, + "shared_chat_delete": null, + "shared_chat_timeout": null, + "shared_chat_unban": null, + "shared_chat_untimeout": null, + "slow": null, + "source_broadcaster_user_id": "117166826", + "source_broadcaster_user_login": "testaccount_420", + "source_broadcaster_user_name": "테스트계정420", + "timeout": null, + "unban": null, + "unban_request": null, + "unmod": null, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + } + ], + "output": [ + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "testaccount_420", + "count": 3, + "displayName": "", + "elements": [ + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "TimestampMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "17:54" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "17:54:06", + "tooltip": "", + "trailingSpace": true, + "type": "TimestampElement" + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "nerixyz" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "nerixyz" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "banned" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "twitchdev" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "twitchdev" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "in" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "UserInfo", + "value": "testaccount_420" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": false, + "type": "TextElement", + "words": [ + "testaccount_420" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + ".", + "(3", + "times)" + ] + } + ], + "flags": "System|Timeout|PubSub|SharedMessage|EventSub|ModerationAction", + "id": "", + "localizedName": "", + "loginName": "", + "messageText": "nerixyz banned twitchdev in testaccount_420. (3 times) ", + "searchText": "nerixyz banned twitchdev in testaccount_420. (3 times) ", + "serverReceivedTime": "2025-02-22T17:54:06Z", + "timeoutUser": "twitchdev", + "userID": "", + "usernameColor": "#ff000000" + } + ] +} diff --git a/tests/snapshots/EventSub/channel-moderate/shared-ban.json b/tests/snapshots/EventSub/channel-moderate/shared-ban.json index de5d14e6..cf9c07b5 100644 --- a/tests/snapshots/EventSub/channel-moderate/shared-ban.json +++ b/tests/snapshots/EventSub/channel-moderate/shared-ban.json @@ -43,7 +43,7 @@ }, "badges": [ ], - "channelName": "", + "channelName": "testaccount_420", "count": 1, "displayName": "", "elements": [ @@ -174,7 +174,7 @@ ] } ], - "flags": "System|Timeout|EventSub|ModerationAction", + "flags": "System|Timeout|PubSub|SharedMessage|EventSub|ModerationAction", "id": "", "localizedName": "", "loginName": "nerixyz",