mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
parent
784fdd28b2
commit
95044efeed
|
@ -10,7 +10,7 @@
|
||||||
- Minor: Added informative messages for recent-messages API's errors. (#3029)
|
- 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 section with helpful Chatterino-related links to the About page. (#3068)
|
||||||
- Minor: Now uses spaces instead of magic Unicode character for sending duplicate messages (#3081)
|
- Minor: Now uses spaces instead of magic Unicode character for sending duplicate messages (#3081)
|
||||||
- Minor: Added `channel.live` filter variable (#3092)
|
- Minor: Added `channel.live` filter variable (#3092, #3110)
|
||||||
- Bugfix: Fixed "smiley" emotes being unable to be "Tabbed" with autocompletion, introduced in v2.3.3. (#3010)
|
- 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: 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)
|
- Bugfix: Copy buttons in usercard now show properly in light mode (#3057)
|
||||||
|
|
|
@ -60,11 +60,6 @@ public:
|
||||||
return this->parser_->valid();
|
return this->parser_->valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool filter(const MessagePtr &message) const
|
|
||||||
{
|
|
||||||
return this->parser_->execute(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool filter(const filterparser::ContextMap &context) const
|
bool filter(const filterparser::ContextMap &context) const
|
||||||
{
|
{
|
||||||
return this->parser_->execute(context);
|
return this->parser_->execute(context);
|
||||||
|
|
|
@ -36,12 +36,13 @@ public:
|
||||||
this->listener_.disconnect();
|
this->listener_.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool filter(const MessagePtr &m) const
|
bool filter(const MessagePtr &m, ChannelPtr channel) const
|
||||||
{
|
{
|
||||||
if (this->filters_.size() == 0)
|
if (this->filters_.size() == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
filterparser::ContextMap context = filterparser::buildContextMap(m);
|
filterparser::ContextMap context =
|
||||||
|
filterparser::buildContextMap(m, channel.get());
|
||||||
for (const auto &f : this->filters_.values())
|
for (const auto &f : this->filters_.values())
|
||||||
{
|
{
|
||||||
if (!f->valid() || !f->filter(context))
|
if (!f->valid() || !f->filter(context))
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#include "FilterParser.hpp"
|
#include "FilterParser.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "common/Channel.hpp"
|
||||||
#include "controllers/filters/parser/Types.hpp"
|
#include "controllers/filters/parser/Types.hpp"
|
||||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||||
|
|
||||||
namespace filterparser {
|
namespace filterparser {
|
||||||
|
|
||||||
ContextMap buildContextMap(const MessagePtr &m)
|
ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel)
|
||||||
{
|
{
|
||||||
auto watchingChannel =
|
auto watchingChannel =
|
||||||
chatterino::getApp()->twitch.server->watchingChannel.get();
|
chatterino::getApp()->twitch.server->watchingChannel.get();
|
||||||
|
@ -83,9 +84,8 @@ ContextMap buildContextMap(const MessagePtr &m)
|
||||||
};
|
};
|
||||||
{
|
{
|
||||||
using namespace chatterino;
|
using namespace chatterino;
|
||||||
auto channel = getApp()->twitch2->getChannelOrEmpty(m->channelName);
|
auto *tc = dynamic_cast<TwitchChannel *>(channel);
|
||||||
auto *tc = dynamic_cast<TwitchChannel *>(channel.get());
|
if (channel && !channel->isEmpty() && tc)
|
||||||
if (!channel->isEmpty() && tc)
|
|
||||||
{
|
{
|
||||||
vars["channel.live"] = tc->isLive();
|
vars["channel.live"] = tc->isLive();
|
||||||
}
|
}
|
||||||
|
@ -104,12 +104,6 @@ FilterParser::FilterParser(const QString &text)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FilterParser::execute(const MessagePtr &message) const
|
|
||||||
{
|
|
||||||
auto context = buildContextMap(message);
|
|
||||||
return this->execute(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FilterParser::execute(const ContextMap &context) const
|
bool FilterParser::execute(const ContextMap &context) const
|
||||||
{
|
{
|
||||||
return this->builtExpression_->execute(context).toBool();
|
return this->builtExpression_->execute(context).toBool();
|
||||||
|
|
|
@ -3,15 +3,20 @@
|
||||||
#include "controllers/filters/parser/Tokenizer.hpp"
|
#include "controllers/filters/parser/Tokenizer.hpp"
|
||||||
#include "controllers/filters/parser/Types.hpp"
|
#include "controllers/filters/parser/Types.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Channel;
|
||||||
|
|
||||||
|
} // namespace chatterino
|
||||||
|
|
||||||
namespace filterparser {
|
namespace filterparser {
|
||||||
|
|
||||||
ContextMap buildContextMap(const MessagePtr &m);
|
ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel);
|
||||||
|
|
||||||
class FilterParser
|
class FilterParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FilterParser(const QString &text);
|
FilterParser(const QString &text);
|
||||||
bool execute(const MessagePtr &message) const;
|
|
||||||
bool execute(const ContextMap &context) const;
|
bool execute(const ContextMap &context) const;
|
||||||
bool valid() const;
|
bool valid() const;
|
||||||
|
|
||||||
|
|
|
@ -754,7 +754,7 @@ bool ChannelView::shouldIncludeMessage(const MessagePtr &m) const
|
||||||
m->loginName, Qt::CaseInsensitive) == 0)
|
m->loginName, Qt::CaseInsensitive) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return this->channelFilters_->filter(m);
|
return this->channelFilters_->filter(m, this->channel_);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -44,7 +44,7 @@ ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accept && filterSet)
|
if (accept && filterSet)
|
||||||
accept = filterSet->filter(message);
|
accept = filterSet->filter(message, channel);
|
||||||
|
|
||||||
// If all predicates match, add the message to the channel
|
// If all predicates match, add the message to the channel
|
||||||
if (accept)
|
if (accept)
|
||||||
|
|
Loading…
Reference in a new issue