Fix emotesets not loading properly (#2905)
* Initial work fk I'm so tired... * Updated Twitch API documentation * Futher changes * Removed debug output * Added changelog entry * Advice: don't code at 4am removed all silly debug stuff * Add missing lambda capture
This commit is contained in:
@@ -761,6 +761,38 @@ void Helix::getCheermotes(
|
||||
.execute();
|
||||
}
|
||||
|
||||
void Helix::getEmoteSetData(QString emoteSetId,
|
||||
ResultCallback<HelixEmoteSetData> successCallback,
|
||||
HelixFailureCallback failureCallback)
|
||||
{
|
||||
QUrlQuery urlQuery;
|
||||
|
||||
urlQuery.addQueryItem("emote_set_id", emoteSetId);
|
||||
|
||||
this->makeRequest("chat/emotes/set", urlQuery)
|
||||
.onSuccess([successCallback, failureCallback,
|
||||
emoteSetId](auto result) -> Outcome {
|
||||
QJsonObject root = result.parseJson();
|
||||
auto data = root.value("data");
|
||||
|
||||
if (!data.isArray())
|
||||
{
|
||||
failureCallback();
|
||||
return Failure;
|
||||
}
|
||||
|
||||
HelixEmoteSetData emoteSetData(data.toArray()[0].toObject());
|
||||
|
||||
successCallback(emoteSetData);
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](NetworkResult result) {
|
||||
// TODO: make better xd
|
||||
failureCallback();
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
|
||||
NetworkRequest Helix::makeRequest(QString url, QUrlQuery urlQuery)
|
||||
{
|
||||
assert(!url.startsWith("/"));
|
||||
|
||||
@@ -264,6 +264,17 @@ struct HelixCheermoteSet {
|
||||
}
|
||||
};
|
||||
|
||||
struct HelixEmoteSetData {
|
||||
QString setId;
|
||||
QString ownerId;
|
||||
|
||||
explicit HelixEmoteSetData(QJsonObject jsonObject)
|
||||
: setId(jsonObject.value("emote_set_id").toString())
|
||||
, ownerId(jsonObject.value("owner_id").toString())
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
enum class HelixClipError {
|
||||
Unknown,
|
||||
ClipsDisabled,
|
||||
@@ -398,6 +409,11 @@ public:
|
||||
ResultCallback<std::vector<HelixCheermoteSet>> successCallback,
|
||||
HelixFailureCallback failureCallback);
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#get-emote-sets
|
||||
void getEmoteSetData(QString emoteSetId,
|
||||
ResultCallback<HelixEmoteSetData> successCallback,
|
||||
HelixFailureCallback failureCallback);
|
||||
|
||||
void update(QString clientId, QString oauthToken);
|
||||
|
||||
static void initialize();
|
||||
|
||||
@@ -157,6 +157,14 @@ URL: https://dev.twitch.tv/docs/api/reference/#get-cheermotes
|
||||
Used in:
|
||||
- `providers/twitch/TwitchChannel.cpp` to resolve a chats available cheer emotes. This helps us parse incoming messages like `pajaCheer1000`
|
||||
|
||||
### Get Emote Sets
|
||||
|
||||
URL: https://dev.twitch.tv/docs/api/reference#get-emote-sets
|
||||
|
||||
- We implement this in `providers/twitch/api/Helix.cpp getEmoteSetData`
|
||||
Used in:
|
||||
- `providers/twitch/TwitchAccount.cpp` to set emoteset owner data upon loading subscriber emotes from Kraken
|
||||
|
||||
## TMI
|
||||
|
||||
The TMI api is undocumented.
|
||||
|
||||
Reference in New Issue
Block a user