mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Add clickable usernames in host offline messages (#2922)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
e1895de7f3
commit
db09a88c8d
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Unversioned
|
||||
|
||||
- Minor: Channel name in `<channel> has gone offline. Exiting host mode.` messages is now clickable. (#2922)
|
||||
- Minor: Added `/openurl` command. Usage: `/openurl <URL>`. Opens the provided URL in the browser. (#2461, #2926)
|
||||
- Bugfix: Fixed large timeout durations in moderation buttons overlapping with usernames or other buttons. (#2865, #2921)
|
||||
|
||||
|
|
|
@ -819,21 +819,26 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
|||
"Usage: \"/delete <msg-id>\" - can't take more "
|
||||
"than one argument"));
|
||||
}
|
||||
else if (tags == "host_on")
|
||||
else if (tags == "host_on" || tags == "host_target_went_offline")
|
||||
{
|
||||
bool hostOn = (tags == "host_on");
|
||||
QStringList parts = msg->messageText.split(QLatin1Char(' '));
|
||||
if (parts.size() != 3)
|
||||
if ((hostOn && parts.size() != 3) || (!hostOn && parts.size() != 7))
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto &channelName = parts[2];
|
||||
auto &channelName = hostOn ? parts[2] : parts[0];
|
||||
if (channelName.size() < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (hostOn)
|
||||
{
|
||||
channelName.chop(1);
|
||||
}
|
||||
MessageBuilder builder;
|
||||
TwitchMessageBuilder::hostingSystemMessage(channelName, &builder);
|
||||
TwitchMessageBuilder::hostingSystemMessage(channelName, &builder,
|
||||
hostOn);
|
||||
channel->addMessage(builder.release());
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1337,18 +1337,34 @@ void TwitchMessageBuilder::offlineSystemMessage(const QString &channelName,
|
|||
}
|
||||
|
||||
void TwitchMessageBuilder::hostingSystemMessage(const QString &channelName,
|
||||
MessageBuilder *builder)
|
||||
MessageBuilder *builder,
|
||||
bool hostOn)
|
||||
{
|
||||
builder->emplace<TimestampElement>();
|
||||
builder->message().flags.set(MessageFlag::System);
|
||||
builder->message().flags.set(MessageFlag::DoNotTriggerNotification);
|
||||
if (hostOn)
|
||||
{
|
||||
builder->emplace<TextElement>("Now hosting", MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
builder
|
||||
->emplace<TextElement>(channelName + ".", MessageElementFlag::Username,
|
||||
->emplace<TextElement>(
|
||||
channelName + ".", MessageElementFlag::Username,
|
||||
MessageColor::System, FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, channelName});
|
||||
}
|
||||
else
|
||||
{
|
||||
builder
|
||||
->emplace<TextElement>(channelName, MessageElementFlag::Username,
|
||||
MessageColor::System,
|
||||
FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, channelName});
|
||||
builder->emplace<TextElement>("has gone offline. Exiting host mode.",
|
||||
MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
}
|
||||
}
|
||||
|
||||
// irc variant
|
||||
void TwitchMessageBuilder::deletionMessage(const MessagePtr originalMessage,
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
static void offlineSystemMessage(const QString &channelName,
|
||||
MessageBuilder *builder);
|
||||
static void hostingSystemMessage(const QString &channelName,
|
||||
MessageBuilder *builder);
|
||||
MessageBuilder *builder, bool hostOn);
|
||||
static void deletionMessage(const MessagePtr originalMessage,
|
||||
MessageBuilder *builder);
|
||||
static void deletionMessage(const DeleteAction &action,
|
||||
|
|
Loading…
Reference in a new issue