diff --git a/CHANGELOG.md b/CHANGELOG.md index 417589177..e048f83be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unversioned +- Minor: Hosting messages are now clickable. (#2655) - Minor: Messages held by automod are now shown to the user. (#2626) - Bugfix: Automod messages now work properly again. (#2682) - Bugfix: `Login expired` message no longer highlights all tabs. (#2735) diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index 17ebf6740..acdb8d86a 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -804,6 +804,23 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message) "Usage: \"/delete \" - can't take more " "than one argument")); } + else if (tags == "host_on") + { + QStringList parts = msg->messageText.split(QLatin1Char(' ')); + if (parts.size() != 3) + { + return; + } + auto &channelName = parts[2]; + if (channelName.size() < 2) + { + return; + } + channelName.chop(1); + MessageBuilder builder; + TwitchMessageBuilder::hostingSystemMessage(channelName, &builder); + channel->addMessage(builder.release()); + } else { channel->addMessage(msg); diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 7d623fcc7..9ce7d606d 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -563,15 +563,17 @@ void TwitchChannel::setLive(bool newLiveStatus) getApp()->windows->sendAlert(); } } - auto live = - makeSystemMessage(this->getDisplayName() + " is live"); - this->addMessage(live); + MessageBuilder builder; + TwitchMessageBuilder::liveSystemMessage(this->getDisplayName(), + &builder); + this->addMessage(builder.release()); } else { - auto offline = - makeSystemMessage(this->getDisplayName() + " is offline"); - this->addMessage(offline); + MessageBuilder builder; + TwitchMessageBuilder::offlineSystemMessage( + this->getDisplayName(), &builder); + this->addMessage(builder.release()); } guard->live = newLiveStatus; } diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 3918e0c45..a433e4de0 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -1302,4 +1302,46 @@ void TwitchMessageBuilder::appendChannelPointRewardMessage( builder->message().flags.set(MessageFlag::RedeemedChannelPointReward); } +void TwitchMessageBuilder::liveSystemMessage(const QString &channelName, + MessageBuilder *builder) +{ + builder->emplace(); + builder->message().flags.set(MessageFlag::System); + builder->message().flags.set(MessageFlag::DoNotTriggerNotification); + builder + ->emplace(channelName, MessageElementFlag::Username, + MessageColor::System, FontStyle::ChatMediumBold) + ->setLink({Link::UserInfo, channelName}); + builder->emplace("is live!", MessageElementFlag::Text, + MessageColor::System); +} + +void TwitchMessageBuilder::offlineSystemMessage(const QString &channelName, + MessageBuilder *builder) +{ + builder->emplace(); + builder->message().flags.set(MessageFlag::System); + builder->message().flags.set(MessageFlag::DoNotTriggerNotification); + builder + ->emplace(channelName, MessageElementFlag::Username, + MessageColor::System, FontStyle::ChatMediumBold) + ->setLink({Link::UserInfo, channelName}); + builder->emplace("is now offline.", MessageElementFlag::Text, + MessageColor::System); +} + +void TwitchMessageBuilder::hostingSystemMessage(const QString &channelName, + MessageBuilder *builder) +{ + builder->emplace(); + builder->message().flags.set(MessageFlag::System); + builder->message().flags.set(MessageFlag::DoNotTriggerNotification); + builder->emplace("Now hosting", MessageElementFlag::Text, + MessageColor::System); + builder + ->emplace(channelName + ".", MessageElementFlag::Username, + MessageColor::System, FontStyle::ChatMediumBold) + ->setLink({Link::UserInfo, channelName}); +} + } // namespace chatterino diff --git a/src/providers/twitch/TwitchMessageBuilder.hpp b/src/providers/twitch/TwitchMessageBuilder.hpp index 368b65299..01bc16b17 100644 --- a/src/providers/twitch/TwitchMessageBuilder.hpp +++ b/src/providers/twitch/TwitchMessageBuilder.hpp @@ -52,6 +52,12 @@ public: static void appendChannelPointRewardMessage( const ChannelPointReward &reward, MessageBuilder *builder); + static void liveSystemMessage(const QString &channelName, + MessageBuilder *builder); + static void offlineSystemMessage(const QString &channelName, + MessageBuilder *builder); + static void hostingSystemMessage(const QString &channelName, + MessageBuilder *builder); private: void parseUsernameColor() override;