Skip to content

Commit

Permalink
Merge commit 'b94e21a600537c444fe184a3f93302763d7db335' into chatterino7
Browse files Browse the repository at this point in the history
Now we're on commit b94e21a; Changes from upstream we've pulled

- Minor: Added middle click split to open in browser (Chatterino#3356)
- Minor: Made join and part message have links to usercards. (Chatterino#3358)
- Minor: Show picked outcome in prediction badges. (Chatterino#3357)
- Minor: Add support for Emoji in IRC (Chatterino#3354)
- Bugfix: Fixed Chatterino attempting to send empty messages (Chatterino#3355)
  • Loading branch information
zneix committed Nov 21, 2021
2 parents d2fe211 + b94e21a commit cfb274a
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unversioned

- Minor: Added middle click split to open in browser (#3356)
- Minor: Added new search predicate to filter for messages matching a regex (#3282)
- Minor: Add `{channel.name}`, `{channel.id}`, `{stream.game}`, `{stream.title}`, `{my.id}`, `{my.name}` placeholders for commands (#3155)
- Minor: Remove TwitchEmotes.com attribution and the open/copy options when right-clicking a Twitch Emote. (#2214, #3136)
Expand Down Expand Up @@ -32,6 +33,9 @@
- Minor: IRC now parses/displays links like Twitch chat. (#3334)
- Minor: Added button & label for copying login name of user instead of display name in the user info popout. (#3335)
- Minor: Make `/delete` errors a bit more verbose (#3350)
- Minor: Made join and part message have links to usercards. (#3358)
- Minor: Show picked outcome in prediction badges. (#3357)
- Minor: Add support for Emoji in IRC (#3354)
- Bugfix: Fixed colored usernames sometimes not working. (#3170)
- Bugfix: Restored ability to send duplicate `/me` messages. (#3166)
- Bugfix: Notifications for moderators about other moderators deleting messages can now be disabled. (#3121)
Expand All @@ -54,6 +58,7 @@
- Bugfix: Fixed IRC ACTION messages (/me) not being colorized properly. (#3341)
- Bugfix: Fixed splits losing filters when closing and reopening them (#3351)
- Bugfix: Fixed the first usercard being broken in `/mods` and `/vips` (#3349)
- Bugfix: Fixed Chatterino attempting to send empty messages (#3355)
- Dev: Add GitHub action to test builds without precompiled headers enabled. (#3327)
- Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103)
- Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038)
Expand Down
11 changes: 7 additions & 4 deletions src/common/ChannelChatters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"

namespace chatterino {

Expand Down Expand Up @@ -34,8 +35,9 @@ void ChannelChatters::addJoinedUser(const QString &user)
QTimer::singleShot(500, &this->lifetimeGuard_, [this] {
auto joinedUsers = this->joinedUsers_.access();

MessageBuilder builder(systemMessage,
"Users joined: " + joinedUsers->join(", "));
MessageBuilder builder;
TwitchMessageBuilder::listOfUsersSystemMessage(
"Users joined:", *joinedUsers, &this->channel_, &builder);
builder->flags.set(MessageFlag::Collapsed);
joinedUsers->clear();
this->channel_.addMessage(builder.release());
Expand All @@ -56,8 +58,9 @@ void ChannelChatters::addPartedUser(const QString &user)
QTimer::singleShot(500, &this->lifetimeGuard_, [this] {
auto partedUsers = this->partedUsers_.access();

MessageBuilder builder(systemMessage,
"Users parted: " + partedUsers->join(", "));
MessageBuilder builder;
TwitchMessageBuilder::listOfUsersSystemMessage(
"Users parted:", *partedUsers, &this->channel_, &builder);
builder->flags.set(MessageFlag::Collapsed);
this->channel_.addMessage(builder.release());
partedUsers->clear();
Expand Down
4 changes: 4 additions & 0 deletions src/providers/irc/IrcChannel2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ IrcChannel::IrcChannel(const QString &name, IrcServer *server)
void IrcChannel::sendMessage(const QString &message)
{
assertInGuiThread();
if (message.isEmpty())
{
return;
}

if (message.startsWith("/"))
{
Expand Down
31 changes: 23 additions & 8 deletions src/providers/irc/IrcMessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ void IrcMessageBuilder::addWords(const QStringList &words)

if (!i.hasNext())
{
this->emplace<TextElement>(string, MessageElementFlag::Text,
textColor);
this->addText(string, textColor);
continue;
}

Expand All @@ -132,10 +131,9 @@ void IrcMessageBuilder::addWords(const QStringList &words)
{
textColor = defaultColor;
}
this->emplace<TextElement>(
string.mid(lastPos, match.capturedStart() - lastPos),
MessageElementFlag::Text, textColor)
->setTrailingSpace(false);
this->addText(
string.mid(lastPos, match.capturedStart() - lastPos),
textColor, false);
lastPos = match.capturedStart() + match.capturedLength();
}
if (!match.captured(1).isEmpty())
Expand Down Expand Up @@ -173,13 +171,30 @@ void IrcMessageBuilder::addWords(const QStringList &words)
{
textColor = defaultColor;
}
this->emplace<TextElement>(string.mid(lastPos),
MessageElementFlag::Text, textColor);
this->addText(string.mid(lastPos), textColor);
}

this->message().elements.back()->setTrailingSpace(false);
}

void IrcMessageBuilder::addText(const QString &text, const QColor &color,
bool addSpace)
{
this->textColor_ = color;
for (auto &variant : getApp()->emotes->emojis.parse(text))
{
boost::apply_visitor(
[&](auto &&arg) {
this->addTextOrEmoji(arg);
},
variant);
if (!addSpace)
{
this->message().elements.back()->setTrailingSpace(false);
}
}
}

void IrcMessageBuilder::appendUsername()
{
QString username = this->userName;
Expand Down
2 changes: 2 additions & 0 deletions src/providers/irc/IrcMessageBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class IrcMessageBuilder : public SharedMessageBuilder
void appendUsername();

void addWords(const QStringList &words);
void addText(const QString &text, const QColor &color,
bool addSpace = true);
};

} // namespace chatterino
4 changes: 2 additions & 2 deletions src/providers/twitch/IrcMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,8 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
auto users = msgParts.at(1)
.mid(1) // there is a space before the first user
.split(", ");
TwitchMessageBuilder::modsOrVipsSystemMessage(msgParts.at(0), users,
tc, &builder);
TwitchMessageBuilder::listOfUsersSystemMessage(msgParts.at(0),
users, tc, &builder);
channel->addMessage(builder.release());
}
else
Expand Down
29 changes: 23 additions & 6 deletions src/providers/twitch/TwitchMessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,22 @@ void TwitchMessageBuilder::appendTwitchBadges()
.arg(subMonths);
}
}
else if (badge.flag_ == MessageElementFlag::BadgePredictions)
{
auto badgeInfoIt = badgeInfos.find(badge.key_);
if (badgeInfoIt != badgeInfos.end())
{
auto predictionText =
badgeInfoIt->second
.replace("\\s", " ") // standard IRC escapes
.replace("\\:", ";")
.replace("\\\\", "\\")
.replace("", ","); // twitch's comma escape
// Careful, the first character is RIGHT LOW PARAPHRASE BRACKET or U+2E1D, which just looks like a comma

tooltip = QString("Predicted %1").arg(predictionText);
}
}

this->emplace<BadgeElement>(badgeEmote.get(), badge.flag_)
->setTooltip(tooltip);
Expand Down Expand Up @@ -1472,17 +1488,18 @@ void TwitchMessageBuilder::deletionMessage(const DeleteAction &action,
builder->message().timeoutUser = "msg:" + action.messageId;
}

void TwitchMessageBuilder::modsOrVipsSystemMessage(QString prefix,
QStringList users,
TwitchChannel *channel,
MessageBuilder *builder)
void TwitchMessageBuilder::listOfUsersSystemMessage(QString prefix,
QStringList users,
Channel *channel,
MessageBuilder *builder)
{
builder->emplace<TimestampElement>();
builder->message().flags.set(MessageFlag::System);
builder->message().flags.set(MessageFlag::DoNotTriggerNotification);
builder->emplace<TextElement>(prefix, MessageElementFlag::Text,
MessageColor::System);
bool isFirst = true;
auto tc = dynamic_cast<TwitchChannel *>(channel);
for (const QString &username : users)
{
if (!isFirst)
Expand All @@ -1495,9 +1512,9 @@ void TwitchMessageBuilder::modsOrVipsSystemMessage(QString prefix,

MessageColor color = MessageColor::System;

if (getSettings()->colorUsernames)
if (tc && getSettings()->colorUsernames)
{
if (auto userColor = channel->getUserColor(username);
if (auto userColor = tc->getUserColor(username);
userColor.isValid())
{
color = MessageColor(userColor);
Expand Down
6 changes: 3 additions & 3 deletions src/providers/twitch/TwitchMessageBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class TwitchMessageBuilder : public SharedMessageBuilder
MessageBuilder *builder);
static void deletionMessage(const DeleteAction &action,
MessageBuilder *builder);
static void modsOrVipsSystemMessage(QString prefix, QStringList users,
TwitchChannel *channel,
MessageBuilder *builder);
static void listOfUsersSystemMessage(QString prefix, QStringList users,
Channel *channel,
MessageBuilder *builder);

private:
void parseUsernameColor() override;
Expand Down
17 changes: 15 additions & 2 deletions src/widgets/helper/ChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,8 +1938,21 @@ void ChannelView::addContextMenuItems(
R"(^(?:https?:\/\/)?(?:www\.|go\.)?twitch\.tv\/(?:popout\/)?(?<username>[a-z0-9_]{3,}))",
QRegularExpression::CaseInsensitiveOption);
static QSet<QString> ignoredUsernames{
"videos", "settings", "directory", "jobs", "friends",
"inventory", "payments", "subscriptions", "messages", "drops",
"directory", //
"downloads", //
"drops", //
"friends", //
"inventory", //
"jobs", //
"messages", //
"payments", //
"profile", //
"security", //
"settings", //
"subscriptions", //
"turbo", //
"videos", //
"wallet", //
};

auto twitchMatch =
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/splits/Split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Split::Split(QWidget *parent)

this->input_->ui_.textEdit->installEventFilter(parent);

// update placeheolder text on Twitch account change and channel change
// update placeholder text on Twitch account change and channel change
this->signalHolder_.managedConnect(
getApp()->accounts->twitch.currentUserChanged, [this] {
this->updateInputPlaceholder();
Expand Down
5 changes: 5 additions & 0 deletions src/widgets/splits/SplitHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,11 @@ void SplitHeader::mousePressEvent(QMouseEvent *event)
menu->popup(this->mapToGlobal(event->pos() + QPoint(0, 4)));
}
break;

case Qt::MiddleButton: {
this->split_->openInBrowser();
}
break;
}

this->doubleClicked_ = false;
Expand Down

0 comments on commit cfb274a

Please sign in to comment.