Add channel.live filter variable (#3092)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL
2021-08-01 14:08:03 +02:00
committed by GitHub
parent 3cb1e5158a
commit d7e8f4eabd
3 changed files with 17 additions and 2 deletions
@@ -61,8 +61,7 @@ ContextMap buildContextMap(const MessagePtr &m)
subLength = m->badgeInfos.at(subBadge).toInt();
}
}
return {
ContextMap vars = {
{"author.badges", std::move(badges)},
{"author.color", m->usernameColor},
{"author.name", m->displayName},
@@ -82,6 +81,20 @@ ContextMap buildContextMap(const MessagePtr &m)
{"message.content", m->messageText},
{"message.length", m->messageText.length()},
};
{
using namespace chatterino;
auto channel = getApp()->twitch2->getChannelOrEmpty(m->channelName);
auto *tc = dynamic_cast<TwitchChannel *>(channel.get());
if (!channel->isEmpty() && tc)
{
vars["channel.live"] = tc->isLive();
}
else
{
vars["channel.live"] = false;
}
}
return vars;
}
FilterParser::FilterParser(const QString &text)
@@ -17,6 +17,7 @@ static const QMap<QString, QString> validIdentifiersMap = {
{"author.sub_length", "author sub length"},
{"channel.name", "channel name"},
{"channel.watching", "/watching channel?"},
{"channel.live", "Channel live?"},
{"flags.highlighted", "highlighted?"},
{"flags.points_redeemed", "redeemed points?"},
{"flags.sub_message", "sub/resub message?"},