mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Make join and part messages have user links (#3358)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
3a5c2b1d33
commit
b94e21a600
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1460,10 +1460,10 @@ 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);
|
||||
|
@ -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);
|
||||
|
|
|
@ -64,9 +64,9 @@ public:
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue