mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Added clickable hosting messages (#2752)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
2f49b23875
commit
1568de6640
|
@ -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)
|
||||
|
|
|
@ -804,6 +804,23 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
|||
"Usage: \"/delete <msg-id>\" - 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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1302,4 +1302,46 @@ void TwitchMessageBuilder::appendChannelPointRewardMessage(
|
|||
builder->message().flags.set(MessageFlag::RedeemedChannelPointReward);
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::liveSystemMessage(const QString &channelName,
|
||||
MessageBuilder *builder)
|
||||
{
|
||||
builder->emplace<TimestampElement>();
|
||||
builder->message().flags.set(MessageFlag::System);
|
||||
builder->message().flags.set(MessageFlag::DoNotTriggerNotification);
|
||||
builder
|
||||
->emplace<TextElement>(channelName, MessageElementFlag::Username,
|
||||
MessageColor::System, FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, channelName});
|
||||
builder->emplace<TextElement>("is live!", MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::offlineSystemMessage(const QString &channelName,
|
||||
MessageBuilder *builder)
|
||||
{
|
||||
builder->emplace<TimestampElement>();
|
||||
builder->message().flags.set(MessageFlag::System);
|
||||
builder->message().flags.set(MessageFlag::DoNotTriggerNotification);
|
||||
builder
|
||||
->emplace<TextElement>(channelName, MessageElementFlag::Username,
|
||||
MessageColor::System, FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, channelName});
|
||||
builder->emplace<TextElement>("is now offline.", MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::hostingSystemMessage(const QString &channelName,
|
||||
MessageBuilder *builder)
|
||||
{
|
||||
builder->emplace<TimestampElement>();
|
||||
builder->message().flags.set(MessageFlag::System);
|
||||
builder->message().flags.set(MessageFlag::DoNotTriggerNotification);
|
||||
builder->emplace<TextElement>("Now hosting", MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
builder
|
||||
->emplace<TextElement>(channelName + ".", MessageElementFlag::Username,
|
||||
MessageColor::System, FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, channelName});
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue