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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View file

@ -9,6 +9,7 @@
- Minor: Received IRC messages use `time` message tag for timestamp if it's available. (#3021)
- Minor: Added informative messages for recent-messages API's errors. (#3029)
- Minor: Added section with helpful Chatterino-related links to the About page. (#3068)
- Minor: Added `channel.live` filter variable (#3092)
- Bugfix: Fixed "smiley" emotes being unable to be "Tabbed" with autocompletion, introduced in v2.3.3. (#3010)
- Bugfix: Fixed PubSub not properly trying to resolve pending listens when the pending listens list was larger than 50. (#3037)
- Bugfix: Copy buttons in usercard now show properly in light mode (#3057)

View file

@ -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)

View file

@ -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?"},