feat: Show FrankerFaceZ channel badges (#5119)

This commit is contained in:
pajlada
2024-02-25 12:18:57 +01:00
committed by GitHub
parent 2815c7b67d
commit 101dc82ea0
10 changed files with 127 additions and 8 deletions
+36
View File
@@ -18,6 +18,7 @@
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/bttv/BttvLiveUpdates.hpp"
#include "providers/bttv/liveupdates/BttvLiveUpdateMessages.hpp"
#include "providers/ffz/FfzBadges.hpp"
#include "providers/ffz/FfzEmotes.hpp"
#include "providers/recentmessages/Api.hpp"
#include "providers/seventv/eventapi/Dispatch.hpp"
@@ -333,6 +334,14 @@ void TwitchChannel::refreshFFZChannelEmotes(bool manualRefresh)
std::forward<decltype(vipBadge)>(vipBadge));
}
},
[this, weak = weakOf<Channel>(this)](auto &&channelBadges) {
if (auto shared = weak.lock())
{
this->tgFfzChannelBadges_.guard();
this->ffzChannelBadges_ =
std::forward<decltype(channelBadges)>(channelBadges);
}
},
manualRefresh);
}
@@ -1707,6 +1716,33 @@ std::optional<EmotePtr> TwitchChannel::twitchBadge(const QString &set,
return std::nullopt;
}
std::vector<FfzBadges::Badge> TwitchChannel::ffzChannelBadges(
const QString &userID) const
{
this->tgFfzChannelBadges_.guard();
auto it = this->ffzChannelBadges_.find(userID);
if (it == this->ffzChannelBadges_.end())
{
return {};
}
std::vector<FfzBadges::Badge> badges;
const auto *ffzBadges = getIApp()->getFfzBadges();
for (const auto &badgeID : it->second)
{
auto badge = ffzBadges->getBadge(badgeID);
if (badge.has_value())
{
badges.emplace_back(*badge);
}
}
return badges;
}
std::optional<EmotePtr> TwitchChannel::ffzCustomModBadge() const
{
return this->ffzCustomModBadge_.get();