feat(eventsub): implement untimeout (#6028)

This commit is contained in:
nerix
2025-03-04 23:00:45 +01:00
committed by GitHub
parent 3dc73e9b84
commit 4b48320eef
7 changed files with 383 additions and 7 deletions
+1 -1
View File
@@ -36,7 +36,7 @@
- Bugfix: Fixed color input thinking blue is also red. (#5982)
- Bugfix: Fixed an issue where commands would sometimes reset if Chatterino was improperly shut down. (#6011)
- 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)
- 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)
- 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)
@@ -215,9 +215,9 @@ struct SharedChatTimeout : public Timeout {
struct Untimeout {
static constexpr std::string_view TAG = "untimeout";
std::string userID;
std::string userLogin;
std::string userName;
String userID;
String userLogin;
String userName;
};
struct SharedChatUntimeout : public Untimeout {
static constexpr std::string_view TAG = "shared_chat_untimeout";
@@ -578,7 +578,7 @@ boost::json::result_for<Untimeout, boost::json::value>::type tag_invoke(
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
}
auto userID = boost::json::try_value_to<std::string>(*jvuserID);
auto userID = boost::json::try_value_to<String>(*jvuserID);
if (userID.has_error())
{
@@ -591,7 +591,7 @@ boost::json::result_for<Untimeout, boost::json::value>::type tag_invoke(
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
}
auto userLogin = boost::json::try_value_to<std::string>(*jvuserLogin);
auto userLogin = boost::json::try_value_to<String>(*jvuserLogin);
if (userLogin.has_error())
{
@@ -604,7 +604,7 @@ boost::json::result_for<Untimeout, boost::json::value>::type tag_invoke(
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
}
auto userName = boost::json::try_value_to<std::string>(*jvuserName);
auto userName = boost::json::try_value_to<String>(*jvuserName);
if (userName.has_error())
{
@@ -303,6 +303,33 @@ void makeModerateMessage(
builder->timeoutUser = action.userLogin.qt();
}
void makeModerateMessage(
EventSubMessageBuilder &builder,
const lib::payload::channel_moderate::v2::Event &event,
const lib::payload::channel_moderate::v2::Untimeout &action)
{
QString text;
bool isShared = event.isFromSharedChat();
builder->flags.set(MessageFlag::Timeout);
builder.appendUser(event.moderatorUserName, event.moderatorUserLogin, text);
builder.emplaceSystemTextAndUpdate("untimedout", text);
builder.appendUser(action.userName, action.userLogin, text, isShared);
if (isShared)
{
builder.emplaceSystemTextAndUpdate("in", text);
builder.appendUser(*event.sourceBroadcasterUserName,
*event.sourceBroadcasterUserLogin, text, false);
}
builder.emplaceSystemTextAndUpdate(".", text);
builder->messageText = text;
builder->searchText = text;
builder->timeoutUser = action.userLogin.qt();
}
void makeModerateMessage(
EventSubMessageBuilder &builder,
const lib::payload::channel_moderate::v2::Event &event,
@@ -70,6 +70,12 @@ void makeModerateMessage(
const lib::payload::channel_moderate::v2::Event &event,
const lib::payload::channel_moderate::v2::Unban &action);
/// <MODERATOR> untimedout <USER>[ in <CHANNEL>].
void makeModerateMessage(
EventSubMessageBuilder &builder,
const lib::payload::channel_moderate::v2::Event &event,
const lib::payload::channel_moderate::v2::Untimeout &action);
/// <MODERATOR> deleted message from <USER>[ in <CHANNEL>] saying: <MESSAGE>
void makeModerateMessage(
EventSubMessageBuilder &builder,
@@ -0,0 +1,188 @@
{
"input": {
"action": "shared_chat_untimeout",
"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": null,
"shared_chat_delete": null,
"shared_chat_timeout": null,
"shared_chat_unban": null,
"shared_chat_untimeout": {
"user_id": "489584266",
"user_login": "uint128",
"user_name": "uint128"
},
"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": "",
"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": "nerixyz",
"words": [
"nerixyz"
]
},
{
"color": "System",
"flags": "Text",
"link": {
"type": "None",
"value": ""
},
"style": "ChatMedium",
"tooltip": "",
"trailingSpace": true,
"type": "TextElement",
"words": [
"untimedout"
]
},
{
"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": [
"in"
]
},
{
"color": "Text",
"fallbackColor": "System",
"flags": "Text|Mention",
"link": {
"type": "None",
"value": ""
},
"style": "ChatMedium",
"tooltip": "",
"trailingSpace": false,
"type": "MentionElement",
"userColor": "System",
"userLoginName": "testaccount_420",
"words": [
"테스트계정420"
]
},
{
"color": "System",
"flags": "Text",
"link": {
"type": "None",
"value": ""
},
"style": "ChatMedium",
"tooltip": "",
"trailingSpace": true,
"type": "TextElement",
"words": [
"."
]
}
],
"flags": "System|Timeout|EventSub",
"id": "",
"localizedName": "",
"loginName": "nerixyz",
"messageText": "nerixyz untimedout uint128 in testaccount_420. ",
"searchText": "nerixyz untimedout uint128 in testaccount_420. ",
"serverReceivedTime": "2024-05-14T12:31:47Z",
"timeoutUser": "uint128",
"userID": "",
"usernameColor": "#ff000000"
}
]
}
@@ -0,0 +1,155 @@
{
"input": {
"action": "untimeout",
"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": 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": {
"user_id": "489584266",
"user_login": "uint128",
"user_name": "uint128"
},
"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": "nerixyz",
"words": [
"nerixyz"
]
},
{
"color": "System",
"flags": "Text",
"link": {
"type": "None",
"value": ""
},
"style": "ChatMedium",
"tooltip": "",
"trailingSpace": true,
"type": "TextElement",
"words": [
"untimedout"
]
},
{
"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|EventSub",
"id": "",
"localizedName": "",
"loginName": "nerixyz",
"messageText": "nerixyz untimedout uint128. ",
"searchText": "nerixyz untimedout uint128. ",
"serverReceivedTime": "2024-05-14T12:31:47Z",
"timeoutUser": "uint128",
"userID": "",
"usernameColor": "#ff000000"
}
]
}