diff --git a/src/common/Aliases.hpp b/src/common/Aliases.hpp index 2dea876b7..36fbc94ff 100644 --- a/src/common/Aliases.hpp +++ b/src/common/Aliases.hpp @@ -34,3 +34,4 @@ QStringAlias(Url); QStringAlias(Tooltip); QStringAlias(EmoteId); QStringAlias(EmoteName); +QStringAlias(EmoteAuthor); diff --git a/src/providers/bttv/BttvEmotes.cpp b/src/providers/bttv/BttvEmotes.cpp index f0ef92060..815e6afa4 100644 --- a/src/providers/bttv/BttvEmotes.cpp +++ b/src/providers/bttv/BttvEmotes.cpp @@ -65,11 +65,12 @@ namespace { return {Success, std::move(emotes)}; } - std::pair parseChannelEmotes(const QJsonObject &jsonRoot) + std::pair parseChannelEmotes(const QJsonObject &jsonRoot, + const QString &userName) { auto emotes = EmoteMap(); - auto innerParse = [&jsonRoot, &emotes](const char *key) { + auto innerParse = [&jsonRoot, &emotes, &userName](const char *key) { auto jsonEmotes = jsonRoot.value(key).toArray(); for (auto jsonEmote_ : jsonEmotes) { @@ -77,6 +78,10 @@ namespace { auto id = EmoteId{jsonEmote.value("id").toString()}; auto name = EmoteName{jsonEmote.value("code").toString()}; + auto author = EmoteAuthor{jsonEmote.value("user") + .toObject() + .value("name") + .toString()}; // emoteObject.value("imageType").toString(); auto emote = Emote({ @@ -86,7 +91,10 @@ namespace { Image::fromUrl(getEmoteLinkV3(id, "2x"), 0.5), Image::fromUrl(getEmoteLinkV3(id, "3x"), 0.25), }, - Tooltip{name.string + "
Channel BetterTTV Emote"}, + Tooltip{name.string + "
Channel BetterTTV Emote" + + ((author.string.isEmpty()) + ? "
By: " + userName.toUtf8() + : "
By: " + author.string)}, Url{emoteLinkFormat.arg(id.string)}, }); @@ -140,15 +148,15 @@ void BttvEmotes::loadEmotes() } void BttvEmotes::loadChannel(std::weak_ptr channel, - const QString &channelId, + const QString &channelId, const QString &userName, std::function callback, bool manualRefresh) { NetworkRequest(QString(bttvChannelEmoteApiUrl) + channelId) .timeout(3000) - .onSuccess([callback = std::move(callback), channel, + .onSuccess([callback = std::move(callback), channel, &userName, manualRefresh](auto result) -> Outcome { - auto pair = parseChannelEmotes(result.parseJson()); + auto pair = parseChannelEmotes(result.parseJson(), userName); if (pair.first) callback(std::move(pair.second)); if (auto shared = channel.lock(); manualRefresh) diff --git a/src/providers/bttv/BttvEmotes.hpp b/src/providers/bttv/BttvEmotes.hpp index 5844e0858..72b21aef4 100644 --- a/src/providers/bttv/BttvEmotes.hpp +++ b/src/providers/bttv/BttvEmotes.hpp @@ -26,7 +26,7 @@ public: boost::optional emote(const EmoteName &name) const; void loadEmotes(); static void loadChannel(std::weak_ptr channel, - const QString &channelId, + const QString &channelId, const QString &userName, std::function callback, bool manualRefresh); diff --git a/src/providers/ffz/FfzEmotes.cpp b/src/providers/ffz/FfzEmotes.cpp index 89f3c9361..dc1b1ab3c 100644 --- a/src/providers/ffz/FfzEmotes.cpp +++ b/src/providers/ffz/FfzEmotes.cpp @@ -128,11 +128,17 @@ namespace { auto id = EmoteId{QString::number(jsonEmote.value("id").toInt())}; auto name = EmoteName{jsonEmote.value("name").toString()}; + auto author = EmoteAuthor{jsonEmote.value("owner") + .toObject() + .value("display_name") + .toString()}; auto urls = jsonEmote.value("urls").toObject(); Emote emote; fillInEmoteData(urls, name, - name.string + "
Channel FFZ Emote", emote); + name.string + "
Channel FFZ Emote" + + "
By: " + author.string, + emote); emote.homePage = Url{QString("https://www.frankerfacez.com/emoticon/%1-%2") .arg(id.string) diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 6e900a7a2..8a9a42aba 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -159,7 +159,7 @@ bool TwitchChannel::canSendMessage() const void TwitchChannel::refreshBTTVChannelEmotes(bool manualRefresh) { BttvEmotes::loadChannel( - weakOf(this), this->roomId(), + weakOf(this), this->roomId(), this->getName(), [this, weak = weakOf(this)](auto &&emoteMap) { if (auto shared = weak.lock()) this->bttvEmotes_.set(