Implement simple ignored phrase system

This commit is contained in:
Rasmus Karlsson
2018-05-13 19:24:32 +02:00
parent 3a48f5db96
commit 15b432a4cf
12 changed files with 266 additions and 31 deletions
@@ -2,6 +2,7 @@
#include "application.hpp"
#include "controllers/highlights/highlightcontroller.hpp"
#include "controllers/ignores/ignorecontroller.hpp"
#include "debug/log.hpp"
#include "providers/twitch/twitchchannel.hpp"
#include "singletons/accountmanager.hpp"
@@ -54,10 +55,12 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
bool TwitchMessageBuilder::isIgnored() const
{
auto app = getApp();
std::shared_ptr<std::vector<QString>> ignoredKeywords = app->settings->getIgnoredKeywords();
for (const QString &keyword : *ignoredKeywords) {
if (this->originalMessage.contains(keyword, Qt::CaseInsensitive)) {
// TODO(pajlada): Do we need to check if the phrase is valid first?
for (const auto &phrase : app->ignores->phrases.getVector()) {
if (phrase.isMatch(this->originalMessage)) {
debug::Log("Blocking message because it contains ignored phrase {}",
phrase.getPattern());
return true;
}
}