Updated chatterino badges api
This commit is contained in:
@@ -20,7 +20,7 @@ AccountController::AccountController()
|
||||
auto it = std::find(accs.begin(), accs.end(), args.item);
|
||||
assert(it != accs.end());
|
||||
|
||||
this->accounts_.removeItem(it - accs.begin());
|
||||
this->accounts_.removeItem(it - accs.begin(), this);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -29,11 +29,13 @@ AccountController::AccountController()
|
||||
{
|
||||
case ProviderId::Twitch:
|
||||
{
|
||||
auto &accs = this->twitch.accounts;
|
||||
auto it = std::find(accs.begin(), accs.end(), args.item);
|
||||
assert(it != accs.end());
|
||||
|
||||
this->twitch.accounts.removeItem(it - accs.begin(), this);
|
||||
if (args.caller != this)
|
||||
{
|
||||
auto accs = this->twitch.accounts.cloneVector();
|
||||
auto it = std::find(accs.begin(), accs.end(), args.item);
|
||||
assert(it != accs.end());
|
||||
this->twitch.accounts.removeItem(it - accs.begin(), this);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ ChatterinoBadges::ChatterinoBadges()
|
||||
{
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> ChatterinoBadges::getBadge(const UserName &username)
|
||||
boost::optional<EmotePtr> ChatterinoBadges::getBadge(const UserId &id)
|
||||
{
|
||||
auto it = badgeMap.find(username.string);
|
||||
auto it = badgeMap.find(id.string);
|
||||
if (it != badgeMap.end())
|
||||
{
|
||||
return emotes[it->second];
|
||||
@@ -34,10 +34,9 @@ boost::optional<EmotePtr> ChatterinoBadges::getBadge(const UserName &username)
|
||||
|
||||
void ChatterinoBadges::loadChatterinoBadges()
|
||||
{
|
||||
static QUrl url("https://fourtf.com/chatterino/badges.json");
|
||||
static QUrl url("https://api.chatterino.com/badges");
|
||||
|
||||
NetworkRequest(url)
|
||||
|
||||
.onSuccess([this](auto result) -> Outcome {
|
||||
auto jsonRoot = result.parseJson();
|
||||
int index = 0;
|
||||
@@ -46,7 +45,9 @@ void ChatterinoBadges::loadChatterinoBadges()
|
||||
auto jsonBadge = jsonBadge_.toObject();
|
||||
auto emote = Emote{
|
||||
EmoteName{},
|
||||
ImageSet{Url{jsonBadge.value("image").toString()}},
|
||||
ImageSet{Url{jsonBadge.value("image1").toString()},
|
||||
Url{jsonBadge.value("image2").toString()},
|
||||
Url{jsonBadge.value("image3").toString()}},
|
||||
Tooltip{jsonBadge.value("tooltip").toString()}, Url{}};
|
||||
|
||||
emotes.push_back(
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
virtual void initialize(Settings &settings, Paths &paths) override;
|
||||
ChatterinoBadges();
|
||||
|
||||
boost::optional<EmotePtr> getBadge(const UserName &username);
|
||||
boost::optional<EmotePtr> getBadge(const UserId &id);
|
||||
|
||||
private:
|
||||
void loadChatterinoBadges();
|
||||
|
||||
@@ -15,8 +15,9 @@ TwitchAccountManager::TwitchAccountManager()
|
||||
currentUser->loadIgnores();
|
||||
});
|
||||
|
||||
this->accounts.itemRemoved.connect(
|
||||
[this](const auto &acc) { this->removeUser(acc.item.get()); });
|
||||
this->accounts.itemRemoved.connect([this](const auto &acc) { //
|
||||
this->removeUser(acc.item.get());
|
||||
});
|
||||
}
|
||||
|
||||
std::shared_ptr<TwitchAccount> TwitchAccountManager::getCurrent()
|
||||
|
||||
@@ -191,6 +191,8 @@ void TwitchMessageBuilder::triggerHighlights()
|
||||
MessagePtr TwitchMessageBuilder::build()
|
||||
{
|
||||
// PARSING
|
||||
this->userId_ = this->ircMessage->tag("user-id").toString();
|
||||
|
||||
this->parseUsername();
|
||||
|
||||
if (this->userName == this->channel->getName())
|
||||
@@ -1276,11 +1278,9 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||
|
||||
void TwitchMessageBuilder::appendChatterinoBadges()
|
||||
{
|
||||
auto chatterinoBadgePtr =
|
||||
getApp()->chatterinoBadges->getBadge({this->userName});
|
||||
if (chatterinoBadgePtr)
|
||||
if (auto badge = getApp()->chatterinoBadges->getBadge({this->userId_}))
|
||||
{
|
||||
this->emplace<BadgeElement>(*chatterinoBadgePtr,
|
||||
this->emplace<BadgeElement>(*badge,
|
||||
MessageElementFlag::BadgeChatterino);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ private:
|
||||
bool hasBits_ = false;
|
||||
bool historicalMessage_ = false;
|
||||
|
||||
QString userId_;
|
||||
QColor usernameColor_;
|
||||
QString originalMessage_;
|
||||
bool senderIsBroadcaster{};
|
||||
|
||||
Reference in New Issue
Block a user