feat: indicate which mods start and cancel raids (#5563)

This commit is contained in:
iProdigy
2024-08-31 03:12:25 -07:00
committed by GitHub
parent af309b726f
commit 956186d1a1
8 changed files with 121 additions and 5 deletions
+10
View File
@@ -172,6 +172,16 @@ struct AutomodInfoAction : PubSubAction {
} type;
};
struct RaidAction : PubSubAction {
using PubSubAction::PubSubAction;
QString target;
};
struct UnraidAction : PubSubAction {
using PubSubAction::PubSubAction;
};
struct WarnAction : PubSubAction {
using PubSubAction::PubSubAction;
+29
View File
@@ -320,6 +320,35 @@ PubSub::PubSub(const QString &host, std::chrono::seconds pingInterval)
this->moderation.userWarned.invoke(action);
};
this->moderationActionHandlers["raid"] = [this](const auto &data,
const auto &roomID) {
RaidAction action(data, roomID);
action.source.id = data.value("created_by_user_id").toString();
action.source.login = data.value("created_by").toString();
const auto args = data.value("args").toArray();
if (args.isEmpty())
{
return;
}
action.target = args[0].toString();
this->moderation.raidStarted.invoke(action);
};
this->moderationActionHandlers["unraid"] = [this](const auto &data,
const auto &roomID) {
UnraidAction action(data, roomID);
action.source.id = data.value("created_by_user_id").toString();
action.source.login = data.value("created_by").toString();
this->moderation.raidCanceled.invoke(action);
};
/*
// This handler is no longer required as we use the automod-queue topic now
this->moderationActionHandlers["automod_rejected"] =
+5
View File
@@ -44,6 +44,8 @@ struct PubSubAutoModQueueMessage;
struct AutomodAction;
struct AutomodUserAction;
struct AutomodInfoAction;
struct RaidAction;
struct UnraidAction;
struct WarnAction;
struct PubSubLowTrustUsersMessage;
struct PubSubWhisperMessage;
@@ -104,6 +106,9 @@ public:
Signal<ModeChangedAction> modeChanged;
Signal<ModerationStateAction> moderationStateChanged;
Signal<RaidAction> raidStarted;
Signal<UnraidAction> raidCanceled;
Signal<BanAction> userBanned;
Signal<UnbanAction> userUnbanned;
Signal<WarnAction> userWarned;
+34
View File
@@ -648,6 +648,40 @@ void TwitchIrcServer::initialize()
});
});
this->connections_.managedConnect(
getApp()->getTwitchPubSub()->moderation.raidStarted,
[this](const auto &action) {
auto chan = this->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
return;
}
auto msg = MessageBuilder(action).release();
postToThread([chan, msg] {
chan->addMessage(msg, MessageContext::Original);
});
});
this->connections_.managedConnect(
getApp()->getTwitchPubSub()->moderation.raidCanceled,
[this](const auto &action) {
auto chan = this->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
return;
}
auto msg = MessageBuilder(action).release();
postToThread([chan, msg] {
chan->addMessage(msg, MessageContext::Original);
});
});
this->connections_.managedConnect(
getApp()->getTwitchPubSub()->pointReward.redeemed, [this](auto &data) {
QString channelId = data.value("channel_id").toString();