Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into chatterino7
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Dec 8, 2024
2 parents bc3794f + e326876 commit 7a067f6
Show file tree
Hide file tree
Showing 22 changed files with 501 additions and 149 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- Minor: Colored usernames now update on the fly when changing the "Color @usernames" setting. (#5300)
- Minor: Added `flags.action` filter variable, allowing you to filter on `/me` messages. (#5397)
- Minor: Added the ability for `/ban`, `/timeout`, `/unban`, and `/untimeout` to specify multiple channels to duplicate the action to. Example: `/timeout --channel id:11148817 --channel testaccount_420 forsen 7m game complaining`. (#5402)
- Minor: The size of the emote popup is now saved. (#5415)
- Minor: The size of the emote popup is now saved. (#5415, #5751)
- Minor: Added the ability to duplicate tabs. (#5277)
- Minor: Improved error messages for channel update commands. (#5429)
- Minor: Moderators can now see when users are warned. (#5441)
Expand All @@ -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, #5759)
- 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)
Expand All @@ -46,6 +47,7 @@
- Minor: Added a setting to hide the scrollbar thumb (the handle you can drag). Hiding the scrollbar thumb will disable mouse click & drag interactions in the scrollbar. (#5731)
- Minor: Added a setting to hide the scrollbar highlights. (#5732)
- Minor: The window layout is now backed up like the other settings. (#5647)
- Minor: Added `flags.similar` filter variable, allowing you to filter messages filtered by the R9K feature. (#5747)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
Expand All @@ -72,7 +74,7 @@
- Bugfix: Fixed incorrect message being disabled in some cases upon approving or denying an automod caught message. (#5611)
- Bugfix: Fixed network requests timing out despite them not being in flight for that long, for Qt 6.3+ where we have the technology. (#5729)
- Bugfix: Fixed double-click selection not working when clicking outside a message. (#5617)
- Bugfix: Fixed a potential rare crash that could occur on Windows if a toast was about to fire just as we were shutting down. (#5728)
- Bugfix: Fixed a rare crash that could occur on Windows if a toast was about to fire just as we were shutting down. (#5728, #5752)
- Bugfix: Fixed emotes starting with ":" not tab-completing. (#5603)
- Bugfix: Fixed 7TV emotes messing with Qt's HTML. (#5677)
- Bugfix: Fixed incorrect messages getting replaced visually. (#5683)
Expand All @@ -84,11 +86,13 @@
- Dev: Update vcpkg build Qt from 6.5.0 to 6.7.0, boost from 1.83.0 to 1.85.0, openssl from 3.1.3 to 3.3.0. (#5422)
- Dev: Unsingletonize `ISoundController`. (#5462)
- Dev: Use Qt's high DPI scaling. (#4868, #5400)
- Dev: Removed cosmetic "Also match the trigger at the end of the message" setting. (#5745)
- Dev: Add doxygen build target. (#5377)
- Dev: Make printing of strings in tests easier. (#5379)
- Dev: Refactor and document `Scrollbar`. (#5334, #5393)
- Dev: Refactor `TwitchIrcServer`, making it abstracted. (#5421, #5435)
- Dev: Reduced the amount of scale events. (#5404, #5406)
- Dev: Refactored settings widget creation. (#5585)
- Dev: Removed unused timegate settings. (#5361)
- Dev: Add `Channel::addSystemMessage` helper function, allowing us to avoid the common `channel->addMessage(makeSystemMessage(...));` pattern. (#5500)
- Dev: Unsingletonize `Resources2`. (#5460)
Expand Down Expand Up @@ -138,7 +142,7 @@
- Dev: 7TV's `entitlement.reset` is now explicitly ignored. (#5685)
- Dev: Qt 6.8 and later now default to the GDI fontengine. (#5710)
- Dev: Moved to condition variables when shutting down worker threads. (#5721, #5733)
- Dev: Reduced layouts in channel views when setting a channel. (#5737)
- Dev: Reduced layouts in channel views when setting a channel. (#5737, #5748, #5757)

## 2.5.1

Expand Down
2 changes: 1 addition & 1 deletion lib/settings
5 changes: 5 additions & 0 deletions resources/qss/settings.qss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ chatterino--DescriptionLabel {
color: #999;
}

QLabel#description {
color: #999;
padding-left: 10px;
}

chatterino--NavigationLabel {
font-family: "Segoe UI light";
font-size: 15px;
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ set(SOURCE_FILES
widgets/settingspages/PluginsPage.hpp
widgets/settingspages/SettingsPage.cpp
widgets/settingspages/SettingsPage.hpp
widgets/settingspages/SettingWidget.cpp
widgets/settingspages/SettingWidget.hpp

widgets/splits/ClosedSplits.cpp
widgets/splits/ClosedSplits.hpp
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/filters/lang/Filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const QMap<QString, Type> MESSAGE_TYPING_CONTEXT{
{"flags.restricted", Type::Bool},
{"flags.monitored", Type::Bool},
{"flags.shared", Type::Bool},
{"flags.similar", Type::Bool},
{"message.content", Type::String},
{"message.length", Type::Int},
{"reward.title", Type::String},
Expand Down Expand Up @@ -144,6 +145,7 @@ ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel)
{"flags.restricted", m->flags.has(MessageFlag::RestrictedMessage)},
{"flags.monitored", m->flags.has(MessageFlag::MonitoredMessage)},
{"flags.shared", m->flags.has(MessageFlag::SharedMessage)},
{"flags.similar", m->flags.has(MessageFlag::Similar)},

{"message.content", m->messageText},
{"message.length", m->messageText.length()},
Expand Down
1 change: 1 addition & 0 deletions src/controllers/filters/lang/Tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const QMap<QString, QString> VALID_IDENTIFIERS_MAP{
{"flags.restricted", "restricted message?"},
{"flags.monitored", "monitored message?"},
{"flags.shared", "shared message?"},
{"flags.similar", "r9k filtered message?"},
{"message.content", "message text"},
{"message.length", "message length"},
{"reward.title", "point reward title"},
Expand Down
5 changes: 2 additions & 3 deletions src/messages/MessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1670,9 +1670,8 @@ std::pair<MessagePtr, MessagePtr> MessageBuilder::makeAutomodMessage(
builder.emplace<BadgeElement>(makeAutoModBadge(),
MessageElementFlag::BadgeChannelAuthority);
// AutoMod "username"
builder2.emplace<TextElement>("AutoMod:", MessageElementFlag::Text,
AUTOMOD_USER_COLOR,
FontStyle::ChatMediumBold);
builder.emplace<TextElement>("AutoMod:", MessageElementFlag::Text,
AUTOMOD_USER_COLOR, FontStyle::ChatMediumBold);
// AutoMod header message
builder.emplace<TextElement>(
("Held a message for reason: " + action.reason +
Expand Down
49 changes: 46 additions & 3 deletions src/providers/twitch/TwitchIrcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions src/providers/twitch/pubsubmessages/AutoMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "util/QMagicEnum.hpp"

#include <QJsonArray>

namespace chatterino {

PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/providers/twitch/pubsubmessages/AutoMod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QColor>
#include <QJsonObject>
#include <QString>
#include <QStringList>

namespace chatterino {

Expand Down Expand Up @@ -40,6 +41,8 @@ struct PubSubAutoModQueueMessage {
QString senderUserDisplayName;
QColor senderUserChatColor;

QStringList blockedTermsFound;

PubSubAutoModQueueMessage() = default;
explicit PubSubAutoModQueueMessage(const QJsonObject &root);
};
Expand Down
7 changes: 4 additions & 3 deletions src/singletons/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,6 @@ class Settings
BoolSetting mentionUsersWithComma = {"/behaviour/mentionUsersWithComma",
true};

/// Commands
BoolSetting allowCommandsAtEnd = {"/commands/allowCommandsAtEnd", false};

/// Emotes
BoolSetting scaleEmotesByLineHeight = {"/emotes/scaleEmotesByLineHeight",
false};
Expand Down Expand Up @@ -362,6 +359,10 @@ class Settings
"/streamerMode/supressLiveNotifications", false};
BoolSetting streamerModeSuppressInlineWhispers = {
"/streamerMode/suppressInlineWhispers", true};
BoolSetting streamerModeHideBlockedTermText = {
"/streamerMode/hideBlockedTermText",
true,
};

/// Ignored Phrases
QStringSetting ignoredPhraseReplace = {"/ignore/ignoredPhraseReplace",
Expand Down
5 changes: 4 additions & 1 deletion src/singletons/Toasts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ using WinToastLib::WinToastTemplate;
Toasts::~Toasts()
{
#ifdef Q_OS_WIN
WinToast::instance()->clear();
if (this->initialized_)
{
WinToast::instance()->clear();
}
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/widgets/Scrollbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Scrollbar : public BaseWidget

boost::circular_buffer<ScrollbarHighlight> highlights_;

bool atBottom_{false};
bool atBottom_{true};
bool hideThumb{false};
/// Controlled by the "Hide scrollbar thumb" setting
bool settingHideThumb{false};
Expand Down
11 changes: 8 additions & 3 deletions src/widgets/dialogs/EmotePopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ void addTwitchEmoteSets(const std::shared_ptr<const EmoteMap> &local,
void loadEmojis(ChannelView &view, const std::vector<EmojiPtr> &emojiMap)
{
ChannelPtr emojiChannel(new Channel("", Channel::Type::None));
// set the channel first to make sure the scrollbar is at the top
view.setChannel(emojiChannel);

emojiChannel->addMessage(makeEmojiMessage(emojiMap),
MessageContext::Original);

view.setChannel(emojiChannel);
}

void loadEmojis(Channel &channel, const std::vector<EmojiPtr> &emojiMap,
Expand Down Expand Up @@ -660,7 +661,11 @@ void EmotePopup::filterEmotes(const QString &searchText)

void EmotePopup::saveBounds() const
{
getApp()->getWindows()->setEmotePopupBounds(this->getBounds());
auto bounds = this->getBounds();
if (!bounds.isNull())
{
getApp()->getWindows()->setEmotePopupBounds(bounds);
}
}

void EmotePopup::resizeEvent(QResizeEvent *event)
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/dialogs/ReplyThreadPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ void ReplyThreadPopup::addMessagesFromThread()
sourceChannel->getName(), Channel::Type::None);
}

this->ui_.threadView->setChannel(this->virtualChannel_);
this->ui_.threadView->setSourceChannel(sourceChannel);

auto rootOverrideFlags =
std::optional<MessageFlags>(this->thread_->root()->flags);
rootOverrideFlags->set(MessageFlag::DoNotLog);
Expand All @@ -258,6 +255,9 @@ void ReplyThreadPopup::addMessagesFromThread()
}
}

this->ui_.threadView->setChannel(this->virtualChannel_);
this->ui_.threadView->setSourceChannel(sourceChannel);

this->messageConnection_ =
std::make_unique<pajlada::Signals::ScopedConnection>(
sourceChannel->messageAppended.connect(
Expand Down
7 changes: 7 additions & 0 deletions src/widgets/helper/ChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,13 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
this->updateID();

this->queueLayout();
if (!this->isVisible() && !this->scrollBar_->isVisible())
{
// If we're not visible and the scrollbar is not (yet) visible,
// we need to make sure that it's at the bottom when this view is laid
// out later.
this->scrollBar_->scrollToBottom();
}
this->queueUpdate();

// Notifications
Expand Down
4 changes: 0 additions & 4 deletions src/widgets/settingspages/CommandPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ CommandPage::CommandPage()
});
}

layout.append(
this->createCheckBox("Also match the trigger at the end of the message",
getSettings()->allowCommandsAtEnd));

QLabel *text = layout.emplace<QLabel>(HELP_TEXT).getElement();
text->setWordWrap(true);
text->setStyleSheet("color: #bbb");
Expand Down
Loading

0 comments on commit 7a067f6

Please sign in to comment.