Add channel.live filter variable (#3092)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -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?"},
|
||||
|
||||
Reference in New Issue
Block a user