mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
improve automod blocked term messaging
This commit is contained in:
parent
5b1ce32a4e
commit
12fa816564
|
@ -4,6 +4,7 @@
|
||||||
#include "common/Channel.hpp"
|
#include "common/Channel.hpp"
|
||||||
#include "common/Common.hpp"
|
#include "common/Common.hpp"
|
||||||
#include "common/Env.hpp"
|
#include "common/Env.hpp"
|
||||||
|
#include "common/Literals.hpp"
|
||||||
#include "common/QLogging.hpp"
|
#include "common/QLogging.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "messages/LimitedQueueSnapshot.hpp"
|
#include "messages/LimitedQueueSnapshot.hpp"
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
#include <pajlada/signals/signalholder.hpp>
|
#include <pajlada/signals/signalholder.hpp>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
#include <QStringBuilder>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -488,9 +490,52 @@ void TwitchIrcServer::initialize()
|
||||||
if (msg.status == "PENDING")
|
if (msg.status == "PENDING")
|
||||||
{
|
{
|
||||||
AutomodAction action(msg.data, channelID);
|
AutomodAction action(msg.data, channelID);
|
||||||
action.reason = QString("%1 level %2")
|
if (msg.reason ==
|
||||||
.arg(msg.contentCategory)
|
PubSubAutoModQueueMessage::Reason::BlockedTerm)
|
||||||
.arg(msg.contentLevel);
|
{
|
||||||
|
auto numBlockedTermsMatched =
|
||||||
|
msg.blockedTermsFound.count();
|
||||||
|
auto hideBlockedTerms =
|
||||||
|
getSettings()
|
||||||
|
->streamerModeHideBlockedTermText &&
|
||||||
|
getApp()->getStreamerMode()->isEnabled();
|
||||||
|
if (!msg.blockedTermsFound.isEmpty())
|
||||||
|
{
|
||||||
|
if (hideBlockedTerms)
|
||||||
|
{
|
||||||
|
action.reason =
|
||||||
|
u"matched " %
|
||||||
|
QString::number(
|
||||||
|
numBlockedTermsMatched) %
|
||||||
|
u" blocked term" %
|
||||||
|
(numBlockedTermsMatched > 1 ? u"s"
|
||||||
|
: u"");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
action.reason =
|
||||||
|
u"matched " %
|
||||||
|
QString::number(
|
||||||
|
numBlockedTermsMatched) %
|
||||||
|
u" blocked term" %
|
||||||
|
(numBlockedTermsMatched > 1 ? u"s"
|
||||||
|
: u"") %
|
||||||
|
u": \"" %
|
||||||
|
msg.blockedTermsFound.join(u"\", \"") %
|
||||||
|
u"\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
action.reason = "blocked term usage";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
action.reason = QString("%1 level %2")
|
||||||
|
.arg(msg.contentCategory)
|
||||||
|
.arg(msg.contentLevel);
|
||||||
|
}
|
||||||
|
|
||||||
action.msgID = msg.messageID;
|
action.msgID = msg.messageID;
|
||||||
action.message = msg.messageText;
|
action.message = msg.messageText;
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "util/QMagicEnum.hpp"
|
#include "util/QMagicEnum.hpp"
|
||||||
|
|
||||||
|
#include <QJsonArray>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
|
PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
|
||||||
|
@ -9,6 +11,7 @@ PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
|
||||||
, data(root.value("data").toObject())
|
, data(root.value("data").toObject())
|
||||||
, status(this->data.value("status").toString())
|
, status(this->data.value("status").toString())
|
||||||
{
|
{
|
||||||
|
qInfo() << "XXX: automod message over pubsub:" << root;
|
||||||
auto oType = qmagicenum::enumCast<Type>(this->typeString);
|
auto oType = qmagicenum::enumCast<Type>(this->typeString);
|
||||||
if (oType.has_value())
|
if (oType.has_value())
|
||||||
{
|
{
|
||||||
|
@ -41,6 +44,27 @@ PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
|
||||||
messageSender.value("display_name").toString();
|
messageSender.value("display_name").toString();
|
||||||
this->senderUserChatColor =
|
this->senderUserChatColor =
|
||||||
QColor(messageSender.value("chat_color").toString());
|
QColor(messageSender.value("chat_color").toString());
|
||||||
|
|
||||||
|
if (this->reason == Reason::BlockedTerm)
|
||||||
|
{
|
||||||
|
// Attempt to read the blocked term(s) that caused this message to be blocked
|
||||||
|
const auto caughtMessageReason =
|
||||||
|
data.value("caught_message_reason").toObject();
|
||||||
|
const auto blockedTermFailure =
|
||||||
|
caughtMessageReason.value("blocked_term_failure").toObject();
|
||||||
|
const auto termsFound =
|
||||||
|
blockedTermFailure.value("terms_found").toArray();
|
||||||
|
|
||||||
|
for (const auto &termValue : termsFound)
|
||||||
|
{
|
||||||
|
const auto term = termValue.toObject();
|
||||||
|
const auto termText = term.value("text").toString();
|
||||||
|
if (!termText.isEmpty())
|
||||||
|
{
|
||||||
|
this->blockedTermsFound.push_back(termText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
@ -40,6 +41,8 @@ struct PubSubAutoModQueueMessage {
|
||||||
QString senderUserDisplayName;
|
QString senderUserDisplayName;
|
||||||
QColor senderUserChatColor;
|
QColor senderUserChatColor;
|
||||||
|
|
||||||
|
QStringList blockedTermsFound;
|
||||||
|
|
||||||
PubSubAutoModQueueMessage() = default;
|
PubSubAutoModQueueMessage() = default;
|
||||||
explicit PubSubAutoModQueueMessage(const QJsonObject &root);
|
explicit PubSubAutoModQueueMessage(const QJsonObject &root);
|
||||||
};
|
};
|
||||||
|
|
|
@ -337,6 +337,10 @@ public:
|
||||||
"/streamerMode/supressLiveNotifications", false};
|
"/streamerMode/supressLiveNotifications", false};
|
||||||
BoolSetting streamerModeSuppressInlineWhispers = {
|
BoolSetting streamerModeSuppressInlineWhispers = {
|
||||||
"/streamerMode/suppressInlineWhispers", true};
|
"/streamerMode/suppressInlineWhispers", true};
|
||||||
|
BoolSetting streamerModeHideBlockedTermText = {
|
||||||
|
"/streamerMode/hideBlockedTermText",
|
||||||
|
true,
|
||||||
|
};
|
||||||
|
|
||||||
/// Ignored Phrases
|
/// Ignored Phrases
|
||||||
QStringSetting ignoredPhraseReplace = {"/ignore/ignoredPhraseReplace",
|
QStringSetting ignoredPhraseReplace = {"/ignore/ignoredPhraseReplace",
|
||||||
|
|
|
@ -667,6 +667,11 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||||
layout.addCheckbox(
|
layout.addCheckbox(
|
||||||
"Hide moderation actions", s.streamerModeHideModActions, false,
|
"Hide moderation actions", s.streamerModeHideModActions, false,
|
||||||
"Hide bans, timeouts, and automod messages from appearing in chat.");
|
"Hide bans, timeouts, and automod messages from appearing in chat.");
|
||||||
|
layout.addCheckbox(
|
||||||
|
"Hide blocked terms", s.streamerModeHideBlockedTermText, false,
|
||||||
|
"Hide blocked terms from showing up in places like AutoMod messages. "
|
||||||
|
"This can be useful in case you have some blocked terms that you don't "
|
||||||
|
"want to show on stream.");
|
||||||
layout.addCheckbox("Mute mention sounds", s.streamerModeMuteMentions, false,
|
layout.addCheckbox("Mute mention sounds", s.streamerModeMuteMentions, false,
|
||||||
"Mute your ping sound from playing.");
|
"Mute your ping sound from playing.");
|
||||||
layout.addCheckbox(
|
layout.addCheckbox(
|
||||||
|
|
Loading…
Reference in a new issue