Communicate streams that went offline through /live (#2880)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL
2021-06-19 19:27:31 +02:00
committed by GitHub
parent f605221042
commit 74960bf419
3 changed files with 26 additions and 0 deletions
+22
View File
@@ -607,10 +607,32 @@ void TwitchChannel::setLive(bool newLiveStatus)
}
else
{
// Channel offline message
MessageBuilder builder;
TwitchMessageBuilder::offlineSystemMessage(
this->getDisplayName(), &builder);
this->addMessage(builder.release());
// "delete" old 'CHANNEL is live' message
LimitedQueueSnapshot<MessagePtr> snapshot =
getApp()->twitch2->liveChannel->getMessageSnapshot();
int snapshotLength = snapshot.size();
// MSVC hates this code if the parens are not there
int end = (std::max)(0, snapshotLength - 200);
auto liveMessageSearchText =
QString("%1 is live!").arg(this->getDisplayName());
for (int i = snapshotLength - 1; i >= end; --i)
{
auto &s = snapshot[i];
if (s->messageText == liveMessageSearchText)
{
s->flags.set(MessageFlag::Disabled);
break;
}
}
}
guard->live = newLiveStatus;
}
@@ -1309,6 +1309,9 @@ void TwitchMessageBuilder::liveMessage(const QString &channelName,
->setLink({Link::UserInfo, channelName});
builder->emplace<TextElement>("is live!", MessageElementFlag::Text,
MessageColor::Text);
auto text = channelName + " is live!";
builder->message().searchText = text;
builder->message().messageText = text;
}
void TwitchMessageBuilder::liveSystemMessage(const QString &channelName,