Make join and part messages have user links (#3358)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL 2021-11-20 13:53:05 +00:00 committed by GitHub
parent 3a5c2b1d33
commit b94e21a600
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 15 deletions

View file

@ -33,6 +33,7 @@
- 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)

View file

@ -2,6 +2,7 @@
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"
namespace chatterino {
@ -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());
@ -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();

View file

@ -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

View file

@ -1460,9 +1460,9 @@ void TwitchMessageBuilder::deletionMessage(const DeleteAction &action,
builder->message().timeoutUser = "msg:" + action.messageId;
}
void TwitchMessageBuilder::modsOrVipsSystemMessage(QString prefix,
void TwitchMessageBuilder::listOfUsersSystemMessage(QString prefix,
QStringList users,
TwitchChannel *channel,
Channel *channel,
MessageBuilder *builder)
{
builder->emplace<TimestampElement>();
@ -1471,6 +1471,7 @@ void TwitchMessageBuilder::modsOrVipsSystemMessage(QString prefix,
builder->emplace<TextElement>(prefix, MessageElementFlag::Text,
MessageColor::System);
bool isFirst = true;
auto tc = dynamic_cast<TwitchChannel *>(channel);
for (const QString &username : users)
{
if (!isFirst)
@ -1483,9 +1484,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);

View file

@ -64,8 +64,8 @@ public:
MessageBuilder *builder);
static void deletionMessage(const DeleteAction &action,
MessageBuilder *builder);
static void modsOrVipsSystemMessage(QString prefix, QStringList users,
TwitchChannel *channel,
static void listOfUsersSystemMessage(QString prefix, QStringList users,
Channel *channel,
MessageBuilder *builder);
private: