Add search predicates for badges and sub tiers (#4013)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
xel86
2022-10-01 08:30:29 -04:00
committed by GitHub
parent b5241670ae
commit bfcc9ff7a4
7 changed files with 191 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#include "messages/search/SubtierPredicate.hpp"
#include "util/Qt.hpp"
namespace chatterino {
SubtierPredicate::SubtierPredicate(const QStringList &subtiers)
{
// Check if any comma-seperated values were passed and transform those
for (const auto &entry : subtiers)
{
for (const auto &subtier : entry.split(',', Qt::SkipEmptyParts))
{
this->subtiers_ << subtier;
}
}
}
bool SubtierPredicate::appliesTo(const Message &message)
{
for (const Badge &badge : message.badges)
{
if (badge.key_ == "subscriber")
{
const auto &subTier =
badge.value_.length() > 3 ? badge.value_.at(0) : '1';
return subtiers_.contains(subTier);
}
}
return false;
}
} // namespace chatterino