Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make raid entry username clickable #5651

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- Minor: Added `--login <username>` CLI argument to specify which account to start logged in as. (#5626)
- Minor: Indicate when subscriptions and resubscriptions are for multiple months. (#5642)
- Minor: Proxy URL information is now included in the `/debug-env` command. (#5648)
- Minor: Make raid entry message usernames clickable. (#5651)
- 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 Down
29 changes: 29 additions & 0 deletions src/messages/MessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,35 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text,
this->message().searchText = text;
}

MessageBuilder::MessageBuilder(RaidEntryMessageTag, const QString &text,
jupjohn marked this conversation as resolved.
Show resolved Hide resolved
jupjohn marked this conversation as resolved.
Show resolved Hide resolved
jupjohn marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
const QString &loginName,
const QString &displayName,
const MessageColor &userColor, const QTime &time)
: MessageBuilder()
{
this->emplace<TimestampElement>(time);

const QStringList textFragments =
text.split(QRegularExpression("\\s"), Qt::SkipEmptyParts);
for (const auto &word : textFragments)
{
jupjohn marked this conversation as resolved.
Show resolved Hide resolved
if (word == displayName)
{
this->emplace<MentionElement>(displayName, loginName,
MessageColor::System, userColor);
continue;
}
jupjohn marked this conversation as resolved.
Show resolved Hide resolved

this->emplace<TextElement>(word, MessageElementFlag::Text,
MessageColor::System);
}

this->message().flags.set(MessageFlag::System);
this->message().flags.set(MessageFlag::DoNotTriggerNotification);
this->message().messageText = text;
this->message().searchText = text;
}

MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &timeoutUser,
const QString &sourceUser,
const QString &systemMessageText, int times,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/MessageBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ namespace linkparser {

struct SystemMessageTag {
};
struct RaidEntryMessageTag {
};
struct TimeoutMessageTag {
};
struct LiveUpdatesUpdateEmoteMessageTag {
Expand All @@ -66,6 +68,7 @@ struct ImageUploaderResultTag {
};

const SystemMessageTag systemMessage{};
const RaidEntryMessageTag raidEntryMessage{};
jupjohn marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
jupjohn marked this conversation as resolved.
Show resolved Hide resolved
jupjohn marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
pajlada marked this conversation as resolved.
Show resolved Hide resolved
const TimeoutMessageTag timeoutMessage{};
const LiveUpdatesUpdateEmoteMessageTag liveUpdatesUpdateEmoteMessage{};
const LiveUpdatesRemoveEmoteMessageTag liveUpdatesRemoveEmoteMessage{};
Expand Down Expand Up @@ -121,6 +124,9 @@ class MessageBuilder

MessageBuilder(SystemMessageTag, const QString &text,
const QTime &time = QTime::currentTime());
MessageBuilder(RaidEntryMessageTag, const QString &text,
const QString &loginName, const QString &displayName,
const MessageColor &userColor, const QTime &time);
MessageBuilder(TimeoutMessageTag, const QString &timeoutUser,
const QString &sourceUser, const QString &systemMessageText,
int times, const QTime &time = QTime::currentTime());
Expand Down
31 changes: 30 additions & 1 deletion src/providers/twitch/IrcMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,35 @@ std::vector<MessagePtr> parseUserNoticeMessage(Channel *channel,
{
messageText = "Announcement";
}
else if (msgType == "raid")
{
auto login = tags.value("login").toString();
auto displayName = tags.value("msg-param-displayName").toString();

if (!login.isEmpty() && !displayName.isEmpty())
{
MessageColor color = MessageColor::System;
if (auto colorTag = tags.value("color").value<QColor>();
colorTag.isValid())
{
color = MessageColor(colorTag);
}

auto b = MessageBuilder(
raidEntryMessage, parseTagString(messageText), login,
displayName, color, calculateMessageTime(message).time());

b->flags.set(MessageFlag::Subscription);
if (mirrored)
{
b->flags.set(MessageFlag::SharedMessage);
}

auto newMessage = b.release();
builtMessages.emplace_back(newMessage);
return builtMessages;
}
}
else if (msgType == "subgift")
{
if (auto monthsIt = tags.find("msg-param-gift-months");
Expand Down Expand Up @@ -600,12 +629,12 @@ std::vector<MessagePtr> parseUserNoticeMessage(Channel *channel,

auto b = MessageBuilder(systemMessage, parseTagString(messageText),
calculateMessageTime(message).time());

b->flags.set(MessageFlag::Subscription);
if (mirrored)
{
b->flags.set(MessageFlag::SharedMessage);
}

auto newMessage = b.release();
builtMessages.emplace_back(newMessage);
}
Expand Down
Loading