feat(eventsub): implement automod message update (#6010)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -510,6 +510,7 @@ private:
|
||||
|
||||
eventsub::SubscriptionHandle eventSubChannelModerateHandle;
|
||||
eventsub::SubscriptionHandle eventSubAutomodMessageHoldHandle;
|
||||
eventsub::SubscriptionHandle eventSubAutomodMessageUpdateHandle;
|
||||
eventsub::SubscriptionHandle eventSubSuspiciousUserMessageHandle;
|
||||
|
||||
friend class TwitchIrcServer;
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user