feat(eventsub): implement automod message update (#6010)

This commit is contained in:
nerix
2025-03-01 15:46:41 +01:00
committed by GitHub
parent bced3c658d
commit 17a44e19bb
11 changed files with 1028 additions and 19 deletions
+18
View File
@@ -1522,6 +1522,22 @@ void TwitchChannel::refreshPubSub()
},
},
});
this->eventSubAutomodMessageUpdateHandle =
getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
.subscriptionType = "automod.message.update",
.subscriptionVersion = "2",
.conditions =
{
{
"broadcaster_user_id",
roomId,
},
{
"moderator_user_id",
currentAccount->getUserId(),
},
},
});
this->eventSubSuspiciousUserMessageHandle =
getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
.subscriptionType = "channel.suspicious_user.message",
@@ -1542,6 +1558,8 @@ void TwitchChannel::refreshPubSub()
else
{
this->eventSubChannelModerateHandle.reset();
this->eventSubAutomodMessageHoldHandle.reset();
this->eventSubAutomodMessageUpdateHandle.reset();
this->eventSubSuspiciousUserMessageHandle.reset();
}
getApp()->getTwitchPubSub()->listenToChannelPointRewards(roomId);
+1
View File
@@ -510,6 +510,7 @@ private:
eventsub::SubscriptionHandle eventSubChannelModerateHandle;
eventsub::SubscriptionHandle eventSubAutomodMessageHoldHandle;
eventsub::SubscriptionHandle eventSubAutomodMessageUpdateHandle;
eventsub::SubscriptionHandle eventSubSuspiciousUserMessageHandle;
friend class TwitchIrcServer;
+20 -4
View File
@@ -232,12 +232,28 @@ void Connection::onAutomodMessageHold(
});
}
void Connection::onAutomodMessageUpdate(
const lib::messages::Metadata &metadata,
const lib::messages::Metadata & /*metadata*/,
const lib::payload::automod_message_update::v2::Payload &payload)
{
(void)metadata;
qCDebug(LOG) << "On automod message update for"
<< payload.event.broadcasterUserLogin.c_str();
auto *channel = dynamic_cast<TwitchChannel *>(
getApp()
->getTwitch()
->getChannelOrEmpty(payload.event.broadcasterUserLogin.qt())
.get());
if (!channel || channel->isEmpty())
{
qCDebug(LOG)
<< "Automod message hold for broadcaster we're not interested in"
<< payload.event.broadcasterUserLogin.qt();
return;
}
// Gray out approve/deny button upon "ALLOWED" and "DENIED" statuses
// They are versions of automod_message_(denied|approved) but for mods.
auto id = "automod_" + payload.event.messageID.qt();
runInGuiThread([channel, id] {
channel->disableMessage(id);
});
}
void Connection::onChannelSuspiciousUserMessage(