mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
1043f9f803
* refactor: remove unnecessary includes in headers * fix: formatting * chore: changelog * fix: scrollbar * fix: suggestions and old appbase remains * fix: suggestion * fix: missing Qt forward declarations * fix: another qt include * fix: includes for precompiled-headers=off * Add missing `<memory>` includes * Add missing `#pragma once` * Fix tests Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
35 lines
860 B
C++
35 lines
860 B
C++
#include "messages/search/SubtierPredicate.hpp"
|
|
|
|
#include "messages/Message.hpp"
|
|
#include "providers/twitch/TwitchBadge.hpp"
|
|
#include "util/Qt.hpp"
|
|
|
|
namespace chatterino {
|
|
|
|
SubtierPredicate::SubtierPredicate(const QString &subtiers, bool negate)
|
|
: MessagePredicate(negate)
|
|
{
|
|
// Check if any comma-seperated values were passed and transform those
|
|
for (const auto &subtier : subtiers.split(',', Qt::SkipEmptyParts))
|
|
{
|
|
this->subtiers_ << subtier;
|
|
}
|
|
}
|
|
|
|
bool SubtierPredicate::appliesToImpl(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
|