mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Add highlight color and show in mentions to automod messages (#5215)
This commit is contained in:
parent
ecad4b052a
commit
c50791972d
|
@ -37,6 +37,8 @@
|
|||
- Minor: Introduce `c2.later()` function to Lua API. (#5154)
|
||||
- Minor: Live streams that are marked as reruns now mark a tab as yellow instead of red. (#5176, #5237)
|
||||
- Minor: Updated to Emoji v15.1. Google emojis are now used as the fallback instead of Twitter emojis. (#5182)
|
||||
- Minor: Added the ability to show AutoMod caught messages in mentions. (#5215)
|
||||
- Minor: Added the ability to configure the color of highlighted AutoMod caught messages. (#5215)
|
||||
- Minor: Allow theming of tab live and rerun indicators. (#5188)
|
||||
- Minor: Added a fallback theme field to custom themes that will be used in case the custom theme does not contain a color Chatterino needs. If no fallback theme is specified, we'll pull the color from the included Dark or Light theme. (#5198)
|
||||
- Minor: Image links now reflect the scale of their image instead of an internal label. (#5201)
|
||||
|
|
|
@ -867,6 +867,14 @@ void Application::initPubSub()
|
|||
p.first);
|
||||
getApp()->twitch->automodChannel->addMessage(
|
||||
p.second);
|
||||
|
||||
if (getSettings()->showAutomodInMentions)
|
||||
{
|
||||
getApp()->twitch->mentionsChannel->addMessage(
|
||||
p.first);
|
||||
getApp()->twitch->mentionsChannel->addMessage(
|
||||
p.second);
|
||||
}
|
||||
});
|
||||
}
|
||||
// "ALLOWED" and "DENIED" statuses remain unimplemented
|
||||
|
|
|
@ -213,6 +213,8 @@ void rebuildMessageHighlights(Settings &settings,
|
|||
settings.enableAutomodHighlightTaskbar.getValue();
|
||||
const auto highlightSoundUrlValue =
|
||||
settings.automodHighlightSoundUrl.getValue();
|
||||
auto highlightColor =
|
||||
ColorProvider::instance().color(ColorType::AutomodHighlight);
|
||||
|
||||
checks.emplace_back(HighlightCheck{
|
||||
[=](const auto & /*args*/, const auto & /*badges*/,
|
||||
|
@ -234,7 +236,7 @@ void rebuildMessageHighlights(Settings &settings,
|
|||
highlightAlert, // alert
|
||||
highlightSound, // playSound
|
||||
highlightSoundUrl, // customSoundUrl
|
||||
nullptr, // color
|
||||
highlightColor, // color
|
||||
false, // showInMentions
|
||||
};
|
||||
}});
|
||||
|
@ -471,6 +473,7 @@ void HighlightController::initialize(Settings &settings,
|
|||
this->rebuildListener_.addSetting(settings.showThreadHighlightInMentions);
|
||||
|
||||
this->rebuildListener_.addSetting(settings.enableAutomodHighlight);
|
||||
this->rebuildListener_.addSetting(settings.showAutomodInMentions);
|
||||
this->rebuildListener_.addSetting(settings.enableAutomodHighlightSound);
|
||||
this->rebuildListener_.addSetting(settings.enableAutomodHighlightTaskbar);
|
||||
this->rebuildListener_.addSetting(settings.automodHighlightSoundUrl);
|
||||
|
|
|
@ -238,9 +238,10 @@ void HighlightModel::afterInit()
|
|||
const std::vector<QStandardItem *> automodRow = this->createRow();
|
||||
setBoolItem(automodRow[Column::Pattern],
|
||||
getSettings()->enableAutomodHighlight.getValue(), true, false);
|
||||
setBoolItem(automodRow[Column::ShowInMentions],
|
||||
getSettings()->showAutomodInMentions.getValue(), true, false);
|
||||
automodRow[Column::Pattern]->setData("AutoMod Caught Messages",
|
||||
Qt::DisplayRole);
|
||||
automodRow[Column::ShowInMentions]->setFlags({});
|
||||
setBoolItem(automodRow[Column::FlashTaskbar],
|
||||
getSettings()->enableAutomodHighlightTaskbar.getValue(), true,
|
||||
false);
|
||||
|
@ -253,8 +254,9 @@ void HighlightModel::afterInit()
|
|||
const auto automodSound =
|
||||
QUrl(getSettings()->automodHighlightSoundUrl.getValue());
|
||||
setFilePathItem(automodRow[Column::SoundPath], automodSound, false);
|
||||
|
||||
automodRow[Column::Color]->setFlags(Qt::ItemFlag::NoItemFlags);
|
||||
auto automodColor =
|
||||
ColorProvider::instance().color(ColorType::AutomodHighlight);
|
||||
setColorItem(automodRow[Column::Color], *automodColor, false);
|
||||
|
||||
this->insertCustomRow(automodRow, HighlightRowIndexes::AutomodRow);
|
||||
}
|
||||
|
@ -322,6 +324,11 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
|||
getSettings()->showThreadHighlightInMentions.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
else if (rowIndex == HighlightRowIndexes::AutomodRow)
|
||||
{
|
||||
getSettings()->showAutomodInMentions.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -502,6 +509,11 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
|||
setColor(getSettings()->threadHighlightColor,
|
||||
ColorType::ThreadMessageHighlight);
|
||||
}
|
||||
else if (rowIndex == HighlightRowIndexes::AutomodRow)
|
||||
{
|
||||
setColor(getSettings()->automodHighlightColor,
|
||||
ColorType::AutomodHighlight);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -21,6 +21,7 @@ QColor HighlightPhrase::FALLBACK_ELEVATED_MESSAGE_HIGHLIGHT_COLOR =
|
|||
QColor HighlightPhrase::FALLBACK_THREAD_HIGHLIGHT_COLOR =
|
||||
QColor(143, 48, 24, 60);
|
||||
QColor HighlightPhrase::FALLBACK_SUB_COLOR = QColor(196, 102, 255, 100);
|
||||
QColor HighlightPhrase::FALLBACK_AUTOMOD_HIGHLIGHT_COLOR = QColor(64, 64, 64);
|
||||
|
||||
bool HighlightPhrase::operator==(const HighlightPhrase &other) const
|
||||
{
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
static QColor FALLBACK_FIRST_MESSAGE_HIGHLIGHT_COLOR;
|
||||
static QColor FALLBACK_ELEVATED_MESSAGE_HIGHLIGHT_COLOR;
|
||||
static QColor FALLBACK_THREAD_HIGHLIGHT_COLOR;
|
||||
static QColor FALLBACK_AUTOMOD_HIGHLIGHT_COLOR;
|
||||
|
||||
private:
|
||||
QString pattern_;
|
||||
|
|
|
@ -69,6 +69,14 @@ ScrollbarHighlight Message::getScrollBarHighlight() const
|
|||
};
|
||||
}
|
||||
|
||||
if (this->flags.has(MessageFlag::AutoModOffendingMessage) ||
|
||||
this->flags.has(MessageFlag::AutoModOffendingMessageHeader))
|
||||
{
|
||||
return {
|
||||
ColorProvider::instance().color(ColorType::AutomodHighlight),
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -51,15 +51,17 @@ enum class MessageFlag : int64_t {
|
|||
LiveUpdatesAdd = (1LL << 28),
|
||||
LiveUpdatesRemove = (1LL << 29),
|
||||
LiveUpdatesUpdate = (1LL << 30),
|
||||
/// The header of a message caught by AutoMod containing allow/disallow
|
||||
AutoModOffendingMessageHeader = (1LL << 31),
|
||||
/// The message caught by AutoMod containing the user who sent the message & its contents
|
||||
AutoModOffendingMessage = (1LL << 31),
|
||||
LowTrustUsers = (1LL << 32),
|
||||
AutoModOffendingMessage = (1LL << 32),
|
||||
LowTrustUsers = (1LL << 33),
|
||||
/// The message is sent by a user marked as restricted with Twitch's "Low Trust"/"Suspicious User" feature
|
||||
RestrictedMessage = (1LL << 33),
|
||||
RestrictedMessage = (1LL << 34),
|
||||
/// The message is sent by a user marked as monitor with Twitch's "Low Trust"/"Suspicious User" feature
|
||||
MonitoredMessage = (1LL << 34),
|
||||
MonitoredMessage = (1LL << 35),
|
||||
/// The message is an ACTION message (/me)
|
||||
Action = (1LL << 35),
|
||||
Action = (1LL << 36),
|
||||
};
|
||||
using MessageFlags = FlagsEnum<MessageFlag>;
|
||||
|
||||
|
|
|
@ -373,7 +373,19 @@ void MessageLayout::updateBuffer(QPixmap *buffer,
|
|||
else if (this->message_->flags.has(MessageFlag::AutoMod) ||
|
||||
this->message_->flags.has(MessageFlag::LowTrustUsers))
|
||||
{
|
||||
backgroundColor = QColor("#404040");
|
||||
if (ctx.preferences.enableAutomodHighlight &&
|
||||
(this->message_->flags.has(MessageFlag::AutoModOffendingMessage) ||
|
||||
this->message_->flags.has(
|
||||
MessageFlag::AutoModOffendingMessageHeader)))
|
||||
{
|
||||
backgroundColor = blendColors(
|
||||
backgroundColor,
|
||||
*ctx.colorProvider.color(ColorType::AutomodHighlight));
|
||||
}
|
||||
else
|
||||
{
|
||||
backgroundColor = QColor("#404040");
|
||||
}
|
||||
}
|
||||
else if (this->message_->flags.has(MessageFlag::Debug))
|
||||
{
|
||||
|
|
|
@ -128,6 +128,9 @@ void ColorProvider::initTypeColorMap()
|
|||
initColor(ColorType::ThreadMessageHighlight,
|
||||
getSettings()->threadHighlightColor,
|
||||
HighlightPhrase::FALLBACK_THREAD_HIGHLIGHT_COLOR);
|
||||
|
||||
initColor(ColorType::AutomodHighlight, getSettings()->automodHighlightColor,
|
||||
HighlightPhrase::FALLBACK_AUTOMOD_HIGHLIGHT_COLOR);
|
||||
}
|
||||
|
||||
void ColorProvider::initDefaultColors()
|
||||
|
|
|
@ -18,6 +18,7 @@ enum class ColorType {
|
|||
ThreadMessageHighlight,
|
||||
// Used in automatic highlights of your own messages
|
||||
SelfMessageHighlight,
|
||||
AutomodHighlight,
|
||||
};
|
||||
|
||||
class ColorProvider
|
||||
|
|
|
@ -2009,6 +2009,7 @@ std::pair<MessagePtr, MessagePtr> TwitchMessageBuilder::makeAutomodMessage(
|
|||
builder.message().flags.set(MessageFlag::PubSub);
|
||||
builder.message().flags.set(MessageFlag::Timeout);
|
||||
builder.message().flags.set(MessageFlag::AutoMod);
|
||||
builder.message().flags.set(MessageFlag::AutoModOffendingMessageHeader);
|
||||
|
||||
// AutoMod shield badge
|
||||
builder.emplace<BadgeElement>(makeAutoModBadge(),
|
||||
|
|
|
@ -394,6 +394,10 @@ public:
|
|||
"/highlighting/automod/enabled",
|
||||
true,
|
||||
};
|
||||
BoolSetting showAutomodInMentions = {
|
||||
"/highlighting/automod/showInMentions",
|
||||
false,
|
||||
};
|
||||
BoolSetting enableAutomodHighlightSound = {
|
||||
"/highlighting/automod/enableSound",
|
||||
false,
|
||||
|
@ -406,6 +410,7 @@ public:
|
|||
"/highlighting/automod/soundUrl",
|
||||
"",
|
||||
};
|
||||
QStringSetting automodHighlightColor = {"/highlighting/automod/color", ""};
|
||||
|
||||
BoolSetting enableThreadHighlight = {
|
||||
"/highlighting/thread/nameIsHighlightKeyword", true};
|
||||
|
|
Loading…
Reference in a new issue