feat: add filter for external badges (#6709)

Co-authored-by: Ava Chow <github@achow101.com>
Reviewed-by: Nerixyz <nerixdev@outlook.de>
This commit is contained in:
pajlada
2026-01-05 16:20:21 +01:00
committed by GitHub
parent 25ea6b9214
commit 327dc0ebcb
186 changed files with 554 additions and 40 deletions
+4 -2
View File
@@ -3,6 +3,8 @@
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
using namespace Qt::StringLiterals;
namespace chatterino {
QString BttvBadges::idForBadge(const QJsonObject &badgeJson) const
@@ -11,10 +13,10 @@ QString BttvBadges::idForBadge(const QJsonObject &badgeJson) const
}
EmotePtr BttvBadges::createBadge(const QString &id,
const QJsonObject & /* badgeJson */) const
const QJsonObject & /*badgeJson*/) const
{
auto emote = Emote{
.name = EmoteName{},
.name = EmoteName{u"betterttv:pro"_s},
.images = ImageSet(Image::fromUrl(Url{id}, 18.0 / 72.0)),
.tooltip = Tooltip{"BTTV Pro"},
.homePage = Url{},
@@ -48,8 +48,9 @@ void ChatterinoBadges::loadChatterinoBadges()
// The sizes for the images are only an estimation, there might
// be badges with different sizes.
constexpr QSize baseSize(18, 18);
auto tooltip = jsonBadge.value("tooltip").toString();
auto emote = Emote{
.name = EmoteName{},
.name = EmoteName{u"chatterino:" % tooltip},
.images =
ImageSet{
Image::fromUrl(
@@ -62,7 +63,7 @@ void ChatterinoBadges::loadChatterinoBadges()
Url{jsonBadge.value("image3").toString()}, 0.25,
baseSize * 4),
},
.tooltip = Tooltip{jsonBadge.value("tooltip").toString()},
.tooltip = Tooltip{tooltip},
.homePage = Url{},
};
+7 -5
View File
@@ -66,7 +66,11 @@ void FfzBadges::load()
jsonBadge["height"].toInt(18));
auto emote = Emote{
.name = EmoteName{},
.name =
EmoteName{
u"frankerfacez:" %
jsonBadge.value("name").toString(),
},
.images =
ImageSet{
Image::fromUrl(
@@ -82,13 +86,11 @@ void FfzBadges::load()
.homePage = Url{},
};
Badge badge;
int badgeID = jsonBadge.value("id").toInt();
this->badges[badgeID] = Badge{
std::make_shared<const Emote>(std::move(emote)),
QColor(jsonBadge.value("color").toString()),
.emote = std::make_shared<const Emote>(std::move(emote)),
.color = QColor(jsonBadge.value("color").toString()),
};
// Find users with this badge
+1
View File
@@ -4,6 +4,7 @@
#include "util/ThreadGuard.hpp"
#include <QColor>
#include <QString>
#include <memory>
#include <optional>
+4 -2
View File
@@ -1,7 +1,7 @@
#include "providers/seventv/SeventvBadges.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
#include "messages/Image.hpp" // IWYU pragma: keep
#include "providers/seventv/SeventvEmotes.hpp"
namespace chatterino {
@@ -15,7 +15,9 @@ EmotePtr SeventvBadges::createBadge(const QString &id,
const QJsonObject &badgeJson) const
{
auto emote = Emote{
.name = EmoteName{},
// We utilize the "emote" "name" for filtering badges, and expect
// the format to be "7tv:badge name" (e.g. "7tv:NNYS 2024")
.name = EmoteName{u"7tv:" % badgeJson["name"].toString()},
.images = SeventvEmotes::createImageSet(badgeJson, true),
.tooltip = Tooltip{badgeJson["tooltip"].toString()},
.homePage = Url{},