Respect follower emotes context, making them only available in their owner channels (#2951)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Paweł
2021-07-11 11:12:49 +02:00
committed by GitHub
parent 2844c8e7e0
commit d5add46730
14 changed files with 180 additions and 28 deletions
+37
View File
@@ -793,6 +793,43 @@ void Helix::getEmoteSetData(QString emoteSetId,
.execute();
}
void Helix::getChannelEmotes(
QString broadcasterId,
ResultCallback<std::vector<HelixChannelEmote>> successCallback,
HelixFailureCallback failureCallback)
{
QUrlQuery urlQuery;
urlQuery.addQueryItem("broadcaster_id", broadcasterId);
this->makeRequest("chat/emotes", urlQuery)
.onSuccess([successCallback,
failureCallback](NetworkResult result) -> Outcome {
QJsonObject root = result.parseJson();
auto data = root.value("data");
if (!data.isArray())
{
failureCallback();
return Failure;
}
std::vector<HelixChannelEmote> channelEmotes;
for (const auto &jsonStream : data.toArray())
{
channelEmotes.emplace_back(jsonStream.toObject());
}
successCallback(channelEmotes);
return Success;
})
.onError([failureCallback](auto result) {
// TODO: make better xd
failureCallback();
})
.execute();
}
NetworkRequest Helix::makeRequest(QString url, QUrlQuery urlQuery)
{
assert(!url.startsWith("/"));
+28
View File
@@ -2,6 +2,7 @@
#include "common/Aliases.hpp"
#include "common/NetworkRequest.hpp"
#include "providers/twitch/TwitchEmotes.hpp"
#include <QJsonArray>
#include <QString>
@@ -267,10 +268,31 @@ struct HelixCheermoteSet {
struct HelixEmoteSetData {
QString setId;
QString ownerId;
QString emoteType;
explicit HelixEmoteSetData(QJsonObject jsonObject)
: setId(jsonObject.value("emote_set_id").toString())
, ownerId(jsonObject.value("owner_id").toString())
, emoteType(jsonObject.value("emote_type").toString())
{
}
};
struct HelixChannelEmote {
const QString emoteId;
const QString name;
const QString type;
const QString setId;
const QString url;
explicit HelixChannelEmote(QJsonObject jsonObject)
: emoteId(jsonObject.value("id").toString())
, name(jsonObject.value("name").toString())
, type(jsonObject.value("emote_type").toString())
, setId(jsonObject.value("emote_set_id").toString())
, url(QString(TWITCH_EMOTE_TEMPLATE)
.replace("{id}", this->emoteId)
.replace("{scale}", "3.0"))
{
}
};
@@ -414,6 +436,12 @@ public:
ResultCallback<HelixEmoteSetData> successCallback,
HelixFailureCallback failureCallback);
// https://dev.twitch.tv/docs/api/reference#get-channel-emotes
void getChannelEmotes(
QString broadcasterId,
ResultCallback<std::vector<HelixChannelEmote>> successCallback,
HelixFailureCallback failureCallback);
void update(QString clientId, QString oauthToken);
static void initialize();
+7
View File
@@ -165,6 +165,13 @@ URL: https://dev.twitch.tv/docs/api/reference#get-emote-sets
Used in:
- `providers/twitch/TwitchAccount.cpp` to set emoteset owner data upon loading subscriber emotes from Kraken
### Get Channel Emotes
URL: https://dev.twitch.tv/docs/api/reference#get-channel-emotes
- We implement this in `providers/twitch/api/Helix.cpp getChannelEmotes`
Not used anywhere at the moment.
## TMI
The TMI api is undocumented.