feat: add setting to hide blocked term automod messages (#5690)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "providers/twitch/pubsubmessages/AutoMod.hpp"
|
||||
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
@@ -143,6 +145,7 @@ struct AutomodAction : PubSubAction {
|
||||
QString message;
|
||||
|
||||
QString reason;
|
||||
PubSubAutoModQueueMessage::Reason reasonCode;
|
||||
|
||||
QString msgID;
|
||||
};
|
||||
|
||||
@@ -349,40 +349,6 @@ PubSub::PubSub(const QString &host, std::chrono::seconds pingInterval)
|
||||
this->moderation.raidCanceled.invoke(action);
|
||||
};
|
||||
|
||||
/*
|
||||
// This handler is no longer required as we use the automod-queue topic now
|
||||
this->moderationActionHandlers["automod_rejected"] =
|
||||
[this](const auto &data, const auto &roomID) {
|
||||
AutomodAction action(data, roomID);
|
||||
|
||||
action.source.id = data.value("created_by_user_id").toString();
|
||||
action.source.login = data.value("created_by").toString();
|
||||
|
||||
action.target.id = data.value("target_user_id").toString();
|
||||
|
||||
const auto args = data.value("args").toArray();
|
||||
|
||||
if (args.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
action.msgID = data.value("msg_id").toString();
|
||||
|
||||
if (action.msgID.isEmpty())
|
||||
{
|
||||
// Missing required msg_id parameter
|
||||
return;
|
||||
}
|
||||
|
||||
action.target.login = args[0].toString();
|
||||
action.message = args[1].toString(); // May be omitted
|
||||
action.reason = args[2].toString(); // May be omitted
|
||||
|
||||
this->moderation.autoModMessageBlocked.invoke(action);
|
||||
};
|
||||
*/
|
||||
|
||||
this->moderationActionHandlers["automod_message_rejected"] =
|
||||
[this](const auto &data, const auto &roomID) {
|
||||
AutomodInfoAction action(data, roomID);
|
||||
|
||||
@@ -494,6 +494,7 @@ void TwitchIrcServer::initialize()
|
||||
|
||||
action.msgID = msg.messageID;
|
||||
action.message = msg.messageText;
|
||||
action.reasonCode = msg.reason;
|
||||
|
||||
// this message also contains per-word automod data, which could be implemented
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
|
||||
this->type = oType.value();
|
||||
}
|
||||
|
||||
this->reason =
|
||||
qmagicenum::enumCast<Reason>(data.value("reason_code").toString())
|
||||
.value_or(Reason::INVALID);
|
||||
|
||||
auto contentClassification =
|
||||
data.value("content_classification").toObject();
|
||||
|
||||
|
||||
@@ -13,15 +13,24 @@ struct PubSubAutoModQueueMessage {
|
||||
|
||||
INVALID,
|
||||
};
|
||||
|
||||
enum class Reason {
|
||||
AutoMod,
|
||||
BlockedTerm,
|
||||
|
||||
INVALID,
|
||||
};
|
||||
|
||||
QString typeString;
|
||||
Type type = Type::INVALID;
|
||||
Reason reason = Reason::INVALID;
|
||||
|
||||
QJsonObject data;
|
||||
|
||||
QString status;
|
||||
|
||||
QString contentCategory;
|
||||
int contentLevel;
|
||||
int contentLevel{};
|
||||
|
||||
QString messageID;
|
||||
QString messageText;
|
||||
@@ -51,3 +60,20 @@ constexpr magic_enum::customize::customize_t magic_enum::customize::enum_name<
|
||||
return default_tag;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr magic_enum::customize::customize_t magic_enum::customize::enum_name<
|
||||
chatterino::PubSubAutoModQueueMessage::Reason>(
|
||||
chatterino::PubSubAutoModQueueMessage::Reason value) noexcept
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case chatterino::PubSubAutoModQueueMessage::Reason::AutoMod:
|
||||
return "AutoModCaughtMessageReason";
|
||||
case chatterino::PubSubAutoModQueueMessage::Reason::BlockedTerm:
|
||||
return "BlockedTermCaughtMessageReason";
|
||||
|
||||
default:
|
||||
return default_tag;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user