feat: improve automod blocked term messaging (#5699)
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
- Minor: When blocking a channel, Chatterino will now warn you about that action. (#5615)
|
||||
- Minor: Indicate when subscriptions and resubscriptions are for multiple months. (#5642)
|
||||
- Minor: Added a setting to control whether or not to show "Blocked Term" automod messages. (#5690)
|
||||
- Minor: Improved AutoMod messaging when messages are blocked due to containing blocked terms. (#5699)
|
||||
- Minor: Proxy URL information is now included in the `/debug-env` command. (#5648)
|
||||
- Minor: Make raid entry message usernames clickable. (#5651)
|
||||
- Minor: Tabs unhighlight when their content is read in other tabs. (#5649)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "common/Channel.hpp"
|
||||
#include "common/Common.hpp"
|
||||
#include "common/Env.hpp"
|
||||
#include "common/Literals.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "messages/LimitedQueueSnapshot.hpp"
|
||||
@@ -147,6 +148,8 @@ bool shouldSendHelixChat()
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
using namespace literals;
|
||||
|
||||
TwitchIrcServer::TwitchIrcServer()
|
||||
: whispersChannel(new Channel("/whispers", Channel::Type::TwitchWhispers))
|
||||
, mentionsChannel(new Channel("/mentions", Channel::Type::TwitchMentions))
|
||||
@@ -488,9 +491,49 @@ void TwitchIrcServer::initialize()
|
||||
if (msg.status == "PENDING")
|
||||
{
|
||||
AutomodAction action(msg.data, channelID);
|
||||
action.reason = QString("%1 level %2")
|
||||
.arg(msg.contentCategory)
|
||||
.arg(msg.contentLevel);
|
||||
if (msg.reason ==
|
||||
PubSubAutoModQueueMessage::Reason::BlockedTerm)
|
||||
{
|
||||
auto numBlockedTermsMatched =
|
||||
msg.blockedTermsFound.count();
|
||||
auto hideBlockedTerms =
|
||||
getSettings()
|
||||
->streamerModeHideBlockedTermText &&
|
||||
getApp()->getStreamerMode()->isEnabled();
|
||||
if (!msg.blockedTermsFound.isEmpty())
|
||||
{
|
||||
if (hideBlockedTerms)
|
||||
{
|
||||
action.reason =
|
||||
u"matches %1 blocked term%2"_s
|
||||
.arg(numBlockedTermsMatched)
|
||||
.arg(numBlockedTermsMatched > 1
|
||||
? u"s"
|
||||
: u"");
|
||||
}
|
||||
else
|
||||
{
|
||||
action.reason =
|
||||
u"matches %1 blocked term%2 \"%3\""_s
|
||||
.arg(numBlockedTermsMatched)
|
||||
.arg(numBlockedTermsMatched > 1
|
||||
? u"s"
|
||||
: u"")
|
||||
.arg(msg.blockedTermsFound.join(
|
||||
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.message = msg.messageText;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "util/QMagicEnum.hpp"
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
|
||||
@@ -41,6 +43,27 @@ PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
|
||||
messageSender.value("display_name").toString();
|
||||
this->senderUserChatColor =
|
||||
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
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QColor>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -40,6 +41,8 @@ struct PubSubAutoModQueueMessage {
|
||||
QString senderUserDisplayName;
|
||||
QColor senderUserChatColor;
|
||||
|
||||
QStringList blockedTermsFound;
|
||||
|
||||
PubSubAutoModQueueMessage() = default;
|
||||
explicit PubSubAutoModQueueMessage(const QJsonObject &root);
|
||||
};
|
||||
|
||||
@@ -347,6 +347,10 @@ public:
|
||||
"/streamerMode/supressLiveNotifications", false};
|
||||
BoolSetting streamerModeSuppressInlineWhispers = {
|
||||
"/streamerMode/suppressInlineWhispers", true};
|
||||
BoolSetting streamerModeHideBlockedTermText = {
|
||||
"/streamerMode/hideBlockedTermText",
|
||||
true,
|
||||
};
|
||||
|
||||
/// Ignored Phrases
|
||||
QStringSetting ignoredPhraseReplace = {"/ignore/ignoredPhraseReplace",
|
||||
|
||||
@@ -675,6 +675,11 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||
layout.addCheckbox(
|
||||
"Hide moderation actions", s.streamerModeHideModActions, false,
|
||||
"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,
|
||||
"Mute your ping sound from playing.");
|
||||
layout.addCheckbox(
|
||||
|
||||
Reference in New Issue
Block a user