diff --git a/CHANGELOG.md b/CHANGELOG.md index 30bfaaf6..70deaaf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ - Bugfix: Fixed the input font not immediately updating when zooming in/out. (#5960) - Bugfix: Fixed color input thinking blue is also red. (#5982) - 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) +- 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) - Dev: Remove unneeded platform specifier for toasts. (#5914) - Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784) - Dev: Removed unused PubSub whisper code. (#5898) diff --git a/lib/twitch-eventsub-ws/include/twitch-eventsub-ws/payloads/channel-moderate-v2.hpp b/lib/twitch-eventsub-ws/include/twitch-eventsub-ws/payloads/channel-moderate-v2.hpp index 8c55bce4..db944074 100644 --- a/lib/twitch-eventsub-ws/include/twitch-eventsub-ws/payloads/channel-moderate-v2.hpp +++ b/lib/twitch-eventsub-ws/include/twitch-eventsub-ws/payloads/channel-moderate-v2.hpp @@ -135,9 +135,9 @@ struct Unvip { struct Mod { static constexpr std::string_view TAG = "mod"; - std::string userID; - std::string userLogin; - std::string userName; + String userID; + String userLogin; + String userName; }; /* user is unmodded @@ -147,9 +147,9 @@ struct Mod { struct Unmod { static constexpr std::string_view TAG = "unmod"; - std::string userID; - std::string userLogin; - std::string userName; + String userID; + String userLogin; + String userName; }; /* user is banned with reason diff --git a/lib/twitch-eventsub-ws/src/generated/payloads/channel-moderate-v2.cpp b/lib/twitch-eventsub-ws/src/generated/payloads/channel-moderate-v2.cpp index 639d9581..e1a77086 100644 --- a/lib/twitch-eventsub-ws/src/generated/payloads/channel-moderate-v2.cpp +++ b/lib/twitch-eventsub-ws/src/generated/payloads/channel-moderate-v2.cpp @@ -213,7 +213,7 @@ boost::json::result_for::type tag_invoke( EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } - auto userID = boost::json::try_value_to(*jvuserID); + auto userID = boost::json::try_value_to(*jvuserID); if (userID.has_error()) { @@ -226,7 +226,7 @@ boost::json::result_for::type tag_invoke( EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } - auto userLogin = boost::json::try_value_to(*jvuserLogin); + auto userLogin = boost::json::try_value_to(*jvuserLogin); if (userLogin.has_error()) { @@ -239,7 +239,7 @@ boost::json::result_for::type tag_invoke( EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } - auto userName = boost::json::try_value_to(*jvuserName); + auto userName = boost::json::try_value_to(*jvuserName); if (userName.has_error()) { @@ -269,7 +269,7 @@ boost::json::result_for::type tag_invoke( EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } - auto userID = boost::json::try_value_to(*jvuserID); + auto userID = boost::json::try_value_to(*jvuserID); if (userID.has_error()) { @@ -282,7 +282,7 @@ boost::json::result_for::type tag_invoke( EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } - auto userLogin = boost::json::try_value_to(*jvuserLogin); + auto userLogin = boost::json::try_value_to(*jvuserLogin); if (userLogin.has_error()) { @@ -295,7 +295,7 @@ boost::json::result_for::type tag_invoke( EVENTSUB_BAIL_HERE(error::Kind::FieldMissing); } - auto userName = boost::json::try_value_to(*jvuserName); + auto userName = boost::json::try_value_to(*jvuserName); if (userName.has_error()) { diff --git a/src/providers/twitch/eventsub/MessageBuilder.cpp b/src/providers/twitch/eventsub/MessageBuilder.cpp index 22bf8590..dd706282 100644 --- a/src/providers/twitch/eventsub/MessageBuilder.cpp +++ b/src/providers/twitch/eventsub/MessageBuilder.cpp @@ -388,4 +388,35 @@ void makeModerateMessage( builder.message().searchText = text; } +void makeModerateMessage(EventSubMessageBuilder &builder, + const lib::payload::channel_moderate::v2::Event &event, + const lib::payload::channel_moderate::v2::Mod &action) +{ + QString text; + + builder.appendUser(event.moderatorUserName, event.moderatorUserLogin, text); + builder.emplaceSystemTextAndUpdate(u"modded"_s, text); + builder.appendUser(action.userName, action.userLogin, text, false); + builder.emplaceSystemTextAndUpdate(u"."_s, text); + + builder.message().messageText = text; + builder.message().searchText = text; +} + +void makeModerateMessage( + EventSubMessageBuilder &builder, + const lib::payload::channel_moderate::v2::Event &event, + const lib::payload::channel_moderate::v2::Unmod &action) +{ + QString text; + + builder.appendUser(event.moderatorUserName, event.moderatorUserLogin, text); + builder.emplaceSystemTextAndUpdate(u"unmodded"_s, text); + builder.appendUser(action.userName, action.userLogin, text, false); + builder.emplaceSystemTextAndUpdate(u"."_s, text); + + builder.message().messageText = text; + builder.message().searchText = text; +} + } // namespace chatterino::eventsub diff --git a/src/providers/twitch/eventsub/MessageBuilder.hpp b/src/providers/twitch/eventsub/MessageBuilder.hpp index d0f2b098..75da3613 100644 --- a/src/providers/twitch/eventsub/MessageBuilder.hpp +++ b/src/providers/twitch/eventsub/MessageBuilder.hpp @@ -122,4 +122,15 @@ void makeModerateMessage( const lib::payload::channel_moderate::v2::Event &event, const lib::payload::channel_moderate::v2::AutomodTerms &action); +/// modded . +void makeModerateMessage(EventSubMessageBuilder &builder, + const lib::payload::channel_moderate::v2::Event &event, + const lib::payload::channel_moderate::v2::Mod &action); + +/// unmodded . +void makeModerateMessage( + EventSubMessageBuilder &builder, + const lib::payload::channel_moderate::v2::Event &event, + const lib::payload::channel_moderate::v2::Unmod &action); + } // namespace chatterino::eventsub diff --git a/tests/snapshots/EventSub/channel-moderate/mod.json b/tests/snapshots/EventSub/channel-moderate/mod.json new file mode 100644 index 00000000..f1e09cfb --- /dev/null +++ b/tests/snapshots/EventSub/channel-moderate/mod.json @@ -0,0 +1,155 @@ +{ + "input": { + "action": "mod", + "automod_terms": null, + "ban": null, + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "delete": null, + "followers": null, + "mod": { + "user_id": "22484632", + "user_login": "forsen", + "user_name": "forsen" + }, + "moderator_user_id": "489584266", + "moderator_user_login": "uint128", + "moderator_user_name": "uint128", + "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": 1, + "displayName": "", + "elements": [ + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "12:31" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "12:31:47", + "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": "uint128", + "words": [ + "uint128" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "modded" + ] + }, + { + "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|EventSub", + "id": "", + "localizedName": "", + "loginName": "uint128", + "messageText": "uint128 modded forsen. ", + "searchText": "uint128 modded forsen. ", + "serverReceivedTime": "2024-05-14T12:31:47Z", + "timeoutUser": "", + "userID": "", + "usernameColor": "#ff000000" + } + ] +} diff --git a/tests/snapshots/EventSub/channel-moderate/unmod.json b/tests/snapshots/EventSub/channel-moderate/unmod.json new file mode 100644 index 00000000..ae4666ed --- /dev/null +++ b/tests/snapshots/EventSub/channel-moderate/unmod.json @@ -0,0 +1,155 @@ +{ + "input": { + "action": "unmod", + "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": "489584266", + "moderator_user_login": "uint128", + "moderator_user_name": "uint128", + "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": { + "user_id": "22484632", + "user_login": "forsen", + "user_name": "forsen" + }, + "unraid": null, + "untimeout": null, + "unvip": null, + "vip": null, + "warn": null + }, + "output": [ + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "", + "count": 1, + "displayName": "", + "elements": [ + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "12:31" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "12:31:47", + "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": "uint128", + "words": [ + "uint128" + ] + }, + { + "color": "System", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "unmodded" + ] + }, + { + "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|EventSub", + "id": "", + "localizedName": "", + "loginName": "uint128", + "messageText": "uint128 unmodded forsen. ", + "searchText": "uint128 unmodded forsen. ", + "serverReceivedTime": "2024-05-14T12:31:47Z", + "timeoutUser": "", + "userID": "", + "usernameColor": "#ff000000" + } + ] +}