diff --git a/CHANGELOG.md b/CHANGELOG.md index b4f669847..be449aabc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/controllers/filters/parser/FilterParser.cpp b/src/controllers/filters/parser/FilterParser.cpp index d7cd18822..7d5e8ad3b 100644 --- a/src/controllers/filters/parser/FilterParser.cpp +++ b/src/controllers/filters/parser/FilterParser.cpp @@ -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(channel.get()); + if (!channel->isEmpty() && tc) + { + vars["channel.live"] = tc->isLive(); + } + else + { + vars["channel.live"] = false; + } + } + return vars; } FilterParser::FilterParser(const QString &text) diff --git a/src/controllers/filters/parser/Tokenizer.hpp b/src/controllers/filters/parser/Tokenizer.hpp index 78ff27064..8f9b5824b 100644 --- a/src/controllers/filters/parser/Tokenizer.hpp +++ b/src/controllers/filters/parser/Tokenizer.hpp @@ -17,6 +17,7 @@ static const QMap 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?"},