mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Purged kraken (#3578)
* Purged kraken code * Remove kraken documentation * Update Helix documentation * Ran prettier * Removed kraken files from qmake build file * Remove now unnecessary .finally() callback
This commit is contained in:
parent
6f7961444f
commit
df70ca59e3
14 changed files with 57 additions and 329 deletions
|
@ -210,7 +210,6 @@ SOURCES += \
|
||||||
src/providers/IvrApi.cpp \
|
src/providers/IvrApi.cpp \
|
||||||
src/providers/LinkResolver.cpp \
|
src/providers/LinkResolver.cpp \
|
||||||
src/providers/twitch/api/Helix.cpp \
|
src/providers/twitch/api/Helix.cpp \
|
||||||
src/providers/twitch/api/Kraken.cpp \
|
|
||||||
src/providers/twitch/ChannelPointReward.cpp \
|
src/providers/twitch/ChannelPointReward.cpp \
|
||||||
src/providers/twitch/IrcMessageHandler.cpp \
|
src/providers/twitch/IrcMessageHandler.cpp \
|
||||||
src/providers/twitch/PubsubActions.cpp \
|
src/providers/twitch/PubsubActions.cpp \
|
||||||
|
@ -455,7 +454,6 @@ HEADERS += \
|
||||||
src/providers/IvrApi.hpp \
|
src/providers/IvrApi.hpp \
|
||||||
src/providers/LinkResolver.hpp \
|
src/providers/LinkResolver.hpp \
|
||||||
src/providers/twitch/api/Helix.hpp \
|
src/providers/twitch/api/Helix.hpp \
|
||||||
src/providers/twitch/api/Kraken.hpp \
|
|
||||||
src/providers/twitch/ChannelPointReward.hpp \
|
src/providers/twitch/ChannelPointReward.hpp \
|
||||||
src/providers/twitch/ChatterinoWebSocketppLogger.hpp \
|
src/providers/twitch/ChatterinoWebSocketppLogger.hpp \
|
||||||
src/providers/twitch/EmoteValue.hpp \
|
src/providers/twitch/EmoteValue.hpp \
|
||||||
|
|
|
@ -239,8 +239,6 @@ set(SOURCE_FILES
|
||||||
|
|
||||||
providers/twitch/api/Helix.cpp
|
providers/twitch/api/Helix.cpp
|
||||||
providers/twitch/api/Helix.hpp
|
providers/twitch/api/Helix.hpp
|
||||||
providers/twitch/api/Kraken.cpp
|
|
||||||
providers/twitch/api/Kraken.hpp
|
|
||||||
|
|
||||||
singletons/Badges.cpp
|
singletons/Badges.cpp
|
||||||
singletons/Badges.hpp
|
singletons/Badges.hpp
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "common/Version.hpp"
|
#include "common/Version.hpp"
|
||||||
#include "providers/IvrApi.hpp"
|
#include "providers/IvrApi.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
#include "providers/twitch/api/Kraken.hpp"
|
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "util/AttachToConsole.hpp"
|
#include "util/AttachToConsole.hpp"
|
||||||
|
@ -83,7 +82,6 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
IvrApi::initialize();
|
IvrApi::initialize();
|
||||||
Helix::initialize();
|
Helix::initialize();
|
||||||
Kraken::initialize();
|
|
||||||
|
|
||||||
Settings settings(paths->settingsDirectory);
|
Settings settings(paths->settingsDirectory);
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ void IvrApi::getSubage(QString userName, QString channelName,
|
||||||
|
|
||||||
void IvrApi::getBulkEmoteSets(QString emoteSetList,
|
void IvrApi::getBulkEmoteSets(QString emoteSetList,
|
||||||
ResultCallback<QJsonArray> successCallback,
|
ResultCallback<QJsonArray> successCallback,
|
||||||
IvrFailureCallback failureCallback,
|
IvrFailureCallback failureCallback)
|
||||||
std::function<void()> finallyCallback)
|
|
||||||
{
|
{
|
||||||
QUrlQuery urlQuery;
|
QUrlQuery urlQuery;
|
||||||
urlQuery.addQueryItem("set_id", emoteSetList);
|
urlQuery.addQueryItem("set_id", emoteSetList);
|
||||||
|
@ -55,7 +54,6 @@ void IvrApi::getBulkEmoteSets(QString emoteSetList,
|
||||||
<< QString(result.getData());
|
<< QString(result.getData());
|
||||||
failureCallback();
|
failureCallback();
|
||||||
})
|
})
|
||||||
.finally(std::move(finallyCallback))
|
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,7 @@ public:
|
||||||
// https://api.ivr.fi/v2/docs/static/index.html#/Twitch/get_twitch_emotes_sets
|
// https://api.ivr.fi/v2/docs/static/index.html#/Twitch/get_twitch_emotes_sets
|
||||||
void getBulkEmoteSets(QString emoteSetList,
|
void getBulkEmoteSets(QString emoteSetList,
|
||||||
ResultCallback<QJsonArray> successCallback,
|
ResultCallback<QJsonArray> successCallback,
|
||||||
IvrFailureCallback failureCallback,
|
IvrFailureCallback failureCallback);
|
||||||
std::function<void()> finallyCallback);
|
|
||||||
|
|
||||||
static void initialize();
|
static void initialize();
|
||||||
|
|
||||||
|
|
|
@ -501,7 +501,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
|
|
||||||
if (emoteSetsChanged)
|
if (emoteSetsChanged)
|
||||||
{
|
{
|
||||||
currentUser->loadUserstateEmotes([] {});
|
currentUser->loadUserstateEmotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString channelName;
|
QString channelName;
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
#include "providers/twitch/TwitchUser.hpp"
|
#include "providers/twitch/TwitchUser.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
#include "providers/twitch/api/Kraken.hpp"
|
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
#include "util/QStringHash.hpp"
|
#include "util/QStringHash.hpp"
|
||||||
#include "util/RapidjsonHelpers.hpp"
|
#include "util/RapidjsonHelpers.hpp"
|
||||||
|
@ -217,18 +216,7 @@ void TwitchAccount::loadEmotes(std::weak_ptr<Channel> weakChannel)
|
||||||
qCDebug(chatterinoTwitch) << "Cleared emotes!";
|
qCDebug(chatterinoTwitch) << "Cleared emotes!";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(zneix): Once Helix adds Get User Emotes we could remove this hacky solution
|
this->loadUserstateEmotes();
|
||||||
// For now, this is necessary as Kraken's equivalent doesn't return all emotes
|
|
||||||
// See: https://twitch.uservoice.com/forums/310213-developers/suggestions/43599900
|
|
||||||
this->loadUserstateEmotes([this, weakChannel] {
|
|
||||||
// Fill up emoteData with emote sets that were returned in a Kraken call, but aren't present in emoteData.
|
|
||||||
this->loadKrakenEmotes();
|
|
||||||
if (auto channel = weakChannel.lock(); channel != nullptr)
|
|
||||||
{
|
|
||||||
channel->addMessage(
|
|
||||||
makeSystemMessage("Twitch subscriber emotes reloaded."));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchAccount::setUserstateEmoteSets(QStringList newEmoteSets)
|
bool TwitchAccount::setUserstateEmoteSets(QStringList newEmoteSets)
|
||||||
|
@ -246,15 +234,14 @@ bool TwitchAccount::setUserstateEmoteSets(QStringList newEmoteSets)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchAccount::loadUserstateEmotes(std::function<void()> callback)
|
void TwitchAccount::loadUserstateEmotes()
|
||||||
{
|
{
|
||||||
if (this->userstateEmoteSets_.isEmpty())
|
if (this->userstateEmoteSets_.isEmpty())
|
||||||
{
|
{
|
||||||
callback();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList newEmoteSetKeys, krakenEmoteSetKeys;
|
QStringList newEmoteSetKeys, existingEmoteSetKeys;
|
||||||
|
|
||||||
auto emoteData = this->emotes_.access();
|
auto emoteData = this->emotes_.access();
|
||||||
auto userEmoteSets = emoteData->emoteSets;
|
auto userEmoteSets = emoteData->emoteSets;
|
||||||
|
@ -262,13 +249,13 @@ void TwitchAccount::loadUserstateEmotes(std::function<void()> callback)
|
||||||
// get list of already fetched emote sets
|
// get list of already fetched emote sets
|
||||||
for (const auto &userEmoteSet : userEmoteSets)
|
for (const auto &userEmoteSet : userEmoteSets)
|
||||||
{
|
{
|
||||||
krakenEmoteSetKeys.push_back(userEmoteSet->key);
|
existingEmoteSetKeys.push_back(userEmoteSet->key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter out emote sets from userstate message, which are not in fetched emote set list
|
// filter out emote sets from userstate message, which are not in fetched emote set list
|
||||||
for (const auto &emoteSetKey : qAsConst(this->userstateEmoteSets_))
|
for (const auto &emoteSetKey : qAsConst(this->userstateEmoteSets_))
|
||||||
{
|
{
|
||||||
if (!krakenEmoteSetKeys.contains(emoteSetKey))
|
if (!existingEmoteSetKeys.contains(emoteSetKey))
|
||||||
{
|
{
|
||||||
newEmoteSetKeys.push_back(emoteSetKey);
|
newEmoteSetKeys.push_back(emoteSetKey);
|
||||||
}
|
}
|
||||||
|
@ -277,7 +264,6 @@ void TwitchAccount::loadUserstateEmotes(std::function<void()> callback)
|
||||||
// return if there are no new emote sets
|
// return if there are no new emote sets
|
||||||
if (newEmoteSetKeys.isEmpty())
|
if (newEmoteSetKeys.isEmpty())
|
||||||
{
|
{
|
||||||
callback();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,16 +351,6 @@ void TwitchAccount::loadUserstateEmotes(std::function<void()> callback)
|
||||||
},
|
},
|
||||||
[] {
|
[] {
|
||||||
// fetching emotes failed, ivr API might be down
|
// fetching emotes failed, ivr API might be down
|
||||||
},
|
|
||||||
[=] {
|
|
||||||
// XXX(zneix): We check if this is the last iteration and if so, call the callback
|
|
||||||
if (i + 1 == batches.size())
|
|
||||||
{
|
|
||||||
qCDebug(chatterinoTwitch)
|
|
||||||
<< "Finished loading emotes from IVR, attempting to "
|
|
||||||
"load Kraken emotes now";
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -484,79 +460,6 @@ void TwitchAccount::autoModDeny(const QString msgID, ChannelPtr channel)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchAccount::loadKrakenEmotes()
|
|
||||||
{
|
|
||||||
getKraken()->getUserEmotes(
|
|
||||||
this,
|
|
||||||
[this](KrakenEmoteSets data) {
|
|
||||||
// no emotes available
|
|
||||||
if (data.emoteSets.isEmpty())
|
|
||||||
{
|
|
||||||
qCWarning(chatterinoTwitch)
|
|
||||||
<< "\"emoticon_sets\" either empty or not present in "
|
|
||||||
"Kraken::getUserEmotes response";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto emoteData = this->emotes_.access();
|
|
||||||
|
|
||||||
for (auto emoteSetIt = data.emoteSets.begin();
|
|
||||||
emoteSetIt != data.emoteSets.end(); ++emoteSetIt)
|
|
||||||
{
|
|
||||||
auto emoteSet = std::make_shared<EmoteSet>();
|
|
||||||
|
|
||||||
QString setKey = emoteSetIt.key();
|
|
||||||
emoteSet->key = setKey;
|
|
||||||
this->loadEmoteSetData(emoteSet);
|
|
||||||
|
|
||||||
// check if the emoteset is already in emoteData
|
|
||||||
auto isAlreadyFetched = std::find_if(
|
|
||||||
emoteData->emoteSets.begin(), emoteData->emoteSets.end(),
|
|
||||||
[setKey](std::shared_ptr<EmoteSet> set) {
|
|
||||||
return (set->key == setKey);
|
|
||||||
});
|
|
||||||
if (isAlreadyFetched != emoteData->emoteSets.end())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto emoteArrObj : emoteSetIt->toArray())
|
|
||||||
{
|
|
||||||
if (!emoteArrObj.isObject())
|
|
||||||
{
|
|
||||||
qCWarning(chatterinoTwitch)
|
|
||||||
<< QString("Emote value from set %1 was invalid")
|
|
||||||
.arg(emoteSet->key);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
KrakenEmote krakenEmote(emoteArrObj.toObject());
|
|
||||||
|
|
||||||
auto id = EmoteId{krakenEmote.id};
|
|
||||||
auto code = EmoteName{
|
|
||||||
TwitchEmotes::cleanUpEmoteCode(krakenEmote.code)};
|
|
||||||
|
|
||||||
emoteSet->emotes.emplace_back(TwitchEmote{id, code});
|
|
||||||
|
|
||||||
if (!emoteSet->local)
|
|
||||||
{
|
|
||||||
auto emote =
|
|
||||||
getApp()->emotes->twitch.getOrCreateEmote(id, code);
|
|
||||||
emoteData->emotes.emplace(code, emote);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::sort(emoteSet->emotes.begin(), emoteSet->emotes.end(),
|
|
||||||
[](const TwitchEmote &l, const TwitchEmote &r) {
|
|
||||||
return l.name.string < r.name.string;
|
|
||||||
});
|
|
||||||
emoteData->emoteSets.emplace_back(emoteSet);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[] {
|
|
||||||
// kraken request failed
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
|
void TwitchAccount::loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet)
|
||||||
{
|
{
|
||||||
if (!emoteSet)
|
if (!emoteSet)
|
||||||
|
|
|
@ -114,7 +114,7 @@ public:
|
||||||
void loadEmotes(std::weak_ptr<Channel> weakChannel = {});
|
void loadEmotes(std::weak_ptr<Channel> weakChannel = {});
|
||||||
// loadUserstateEmotes loads emote sets that are part of the USERSTATE emote-sets key
|
// loadUserstateEmotes loads emote sets that are part of the USERSTATE emote-sets key
|
||||||
// this function makes sure not to load emote sets that have already been loaded
|
// this function makes sure not to load emote sets that have already been loaded
|
||||||
void loadUserstateEmotes(std::function<void()> callback);
|
void loadUserstateEmotes();
|
||||||
// setUserStateEmoteSets sets the emote sets that were parsed from the USERSTATE emote-sets key
|
// setUserStateEmoteSets sets the emote sets that were parsed from the USERSTATE emote-sets key
|
||||||
// Returns true if the newly inserted emote sets differ from the ones previously saved
|
// Returns true if the newly inserted emote sets differ from the ones previously saved
|
||||||
[[nodiscard]] bool setUserstateEmoteSets(QStringList newEmoteSets);
|
[[nodiscard]] bool setUserstateEmoteSets(QStringList newEmoteSets);
|
||||||
|
@ -127,7 +127,6 @@ public:
|
||||||
void autoModDeny(const QString msgID, ChannelPtr channel);
|
void autoModDeny(const QString msgID, ChannelPtr channel);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadKrakenEmotes();
|
|
||||||
void loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet);
|
void loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet);
|
||||||
|
|
||||||
QString oauthClient_;
|
QString oauthClient_;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
#include "providers/twitch/api/Kraken.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
@ -149,7 +148,6 @@ void TwitchAccountManager::load()
|
||||||
qCDebug(chatterinoTwitch)
|
qCDebug(chatterinoTwitch)
|
||||||
<< "Twitch user updated to" << newUsername;
|
<< "Twitch user updated to" << newUsername;
|
||||||
getHelix()->update(user->getOAuthClient(), user->getOAuthToken());
|
getHelix()->update(user->getOAuthClient(), user->getOAuthToken());
|
||||||
getKraken()->update(user->getOAuthClient(), user->getOAuthToken());
|
|
||||||
this->currentUser_ = user;
|
this->currentUser_ = user;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
#include "providers/twitch/api/Kraken.hpp"
|
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/Toasts.hpp"
|
#include "singletons/Toasts.hpp"
|
||||||
|
|
|
@ -1,86 +0,0 @@
|
||||||
#include "providers/twitch/api/Kraken.hpp"
|
|
||||||
|
|
||||||
#include "common/Outcome.hpp"
|
|
||||||
#include "common/QLogging.hpp"
|
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
static Kraken *instance = nullptr;
|
|
||||||
|
|
||||||
void Kraken::getUserEmotes(TwitchAccount *account,
|
|
||||||
ResultCallback<KrakenEmoteSets> successCallback,
|
|
||||||
KrakenFailureCallback failureCallback)
|
|
||||||
{
|
|
||||||
this->makeRequest(QString("users/%1/emotes").arg(account->getUserId()), {})
|
|
||||||
.authorizeTwitchV5(account->getOAuthClient(), account->getOAuthToken())
|
|
||||||
.onSuccess([successCallback](auto result) -> Outcome {
|
|
||||||
auto data = result.parseJson();
|
|
||||||
|
|
||||||
KrakenEmoteSets emoteSets(data);
|
|
||||||
|
|
||||||
successCallback(emoteSets);
|
|
||||||
|
|
||||||
return Success;
|
|
||||||
})
|
|
||||||
.onError([failureCallback](NetworkResult /*result*/) {
|
|
||||||
// TODO: make better xd
|
|
||||||
failureCallback();
|
|
||||||
})
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkRequest Kraken::makeRequest(QString url, QUrlQuery urlQuery)
|
|
||||||
{
|
|
||||||
assert(!url.startsWith("/"));
|
|
||||||
|
|
||||||
if (this->clientId.isEmpty())
|
|
||||||
{
|
|
||||||
qCDebug(chatterinoTwitch)
|
|
||||||
<< "Kraken::makeRequest called without a client ID set BabyRage";
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString baseUrl("https://api.twitch.tv/kraken/");
|
|
||||||
|
|
||||||
QUrl fullUrl(baseUrl + url);
|
|
||||||
|
|
||||||
fullUrl.setQuery(urlQuery);
|
|
||||||
|
|
||||||
if (!this->oauthToken.isEmpty())
|
|
||||||
{
|
|
||||||
return NetworkRequest(fullUrl)
|
|
||||||
.timeout(5 * 1000)
|
|
||||||
.header("Accept", "application/vnd.twitchtv.v5+json")
|
|
||||||
.header("Client-ID", this->clientId)
|
|
||||||
.header("Authorization", "OAuth " + this->oauthToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NetworkRequest(fullUrl)
|
|
||||||
.timeout(5 * 1000)
|
|
||||||
.header("Accept", "application/vnd.twitchtv.v5+json")
|
|
||||||
.header("Client-ID", this->clientId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Kraken::update(QString clientId, QString oauthToken)
|
|
||||||
{
|
|
||||||
this->clientId = std::move(clientId);
|
|
||||||
this->oauthToken = std::move(oauthToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Kraken::initialize()
|
|
||||||
{
|
|
||||||
assert(instance == nullptr);
|
|
||||||
|
|
||||||
instance = new Kraken();
|
|
||||||
|
|
||||||
getKraken()->update(getDefaultClientID(), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
Kraken *getKraken()
|
|
||||||
{
|
|
||||||
assert(instance != nullptr);
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -1,59 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common/NetworkRequest.hpp"
|
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QUrlQuery>
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
using KrakenFailureCallback = std::function<void()>;
|
|
||||||
template <typename... T>
|
|
||||||
using ResultCallback = std::function<void(T...)>;
|
|
||||||
|
|
||||||
struct KrakenEmoteSets {
|
|
||||||
const QJsonObject emoteSets;
|
|
||||||
|
|
||||||
KrakenEmoteSets(QJsonObject jsonObject)
|
|
||||||
: emoteSets(jsonObject.value("emoticon_sets").toObject())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct KrakenEmote {
|
|
||||||
const QString code;
|
|
||||||
const QString id;
|
|
||||||
|
|
||||||
KrakenEmote(QJsonObject jsonObject)
|
|
||||||
: code(jsonObject.value("code").toString())
|
|
||||||
, id(QString::number(jsonObject.value("id").toInt()))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Kraken final : boost::noncopyable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// https://dev.twitch.tv/docs/v5/reference/users#get-user-emotes
|
|
||||||
void getUserEmotes(TwitchAccount *account,
|
|
||||||
ResultCallback<KrakenEmoteSets> successCallback,
|
|
||||||
KrakenFailureCallback failureCallback);
|
|
||||||
|
|
||||||
void update(QString clientId, QString oauthToken);
|
|
||||||
|
|
||||||
static void initialize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
NetworkRequest makeRequest(QString url, QUrlQuery urlQuery);
|
|
||||||
|
|
||||||
QString clientId;
|
|
||||||
QString oauthToken;
|
|
||||||
};
|
|
||||||
|
|
||||||
Kraken *getKraken();
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -2,19 +2,6 @@
|
||||||
|
|
||||||
this folder describes what sort of API requests we do, what permissions are required for the requests etc
|
this folder describes what sort of API requests we do, what permissions are required for the requests etc
|
||||||
|
|
||||||
## Kraken (V5)
|
|
||||||
|
|
||||||
We use few Kraken endpoints in Chatterino2.
|
|
||||||
|
|
||||||
### Get User Emotes
|
|
||||||
|
|
||||||
URL: https://dev.twitch.tv/docs/v5/reference/users#get-user-emotes
|
|
||||||
Requires `user_subscriptions` scope
|
|
||||||
|
|
||||||
Migration path: **Unknown**
|
|
||||||
|
|
||||||
- We use this in `providers/twitch/TwitchAccount.cpp loadEmotes` to figure out which emotes a user is allowed to use!
|
|
||||||
|
|
||||||
## Helix
|
## Helix
|
||||||
|
|
||||||
Full Helix API reference: https://dev.twitch.tv/docs/api/reference
|
Full Helix API reference: https://dev.twitch.tv/docs/api/reference
|
||||||
|
@ -23,8 +10,8 @@ Full Helix API reference: https://dev.twitch.tv/docs/api/reference
|
||||||
|
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#get-users
|
URL: https://dev.twitch.tv/docs/api/reference#get-users
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp fetchUsers`.
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `UserInfoPopup` to get ID, viewCount, displayName, createdAt of username we clicked
|
- `UserInfoPopup` to get ID, viewCount, displayName, createdAt of username we clicked
|
||||||
- `CommandController` to power any commands that need to get a user ID
|
- `CommandController` to power any commands that need to get a user ID
|
||||||
- `Toasts` to get the profile picture of a streamer who just went live
|
- `Toasts` to get the profile picture of a streamer who just went live
|
||||||
|
@ -34,16 +21,16 @@ URL: https://dev.twitch.tv/docs/api/reference#get-users
|
||||||
|
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#get-users-follows
|
URL: https://dev.twitch.tv/docs/api/reference#get-users-follows
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp fetchUsersFollows`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `UserInfoPopup` to get number of followers a user has
|
- `UserInfoPopup` to get number of followers a user has
|
||||||
|
|
||||||
### Get Streams
|
### Get Streams
|
||||||
|
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#get-streams
|
URL: https://dev.twitch.tv/docs/api/reference#get-streams
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp fetchStreams`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `TwitchChannel` to get live status, game, title, and viewer count of a channel
|
- `TwitchChannel` to get live status, game, title, and viewer count of a channel
|
||||||
- `NotificationController` to provide notifications for channels you might not have open in Chatterino, but are still interested in getting notifications for
|
- `NotificationController` to provide notifications for channels you might not have open in Chatterino, but are still interested in getting notifications for
|
||||||
|
|
||||||
|
@ -52,16 +39,16 @@ URL: https://dev.twitch.tv/docs/api/reference#get-streams
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#create-clip
|
URL: https://dev.twitch.tv/docs/api/reference#create-clip
|
||||||
Requires `clips:edit` scope
|
Requires `clips:edit` scope
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp createClip`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `TwitchChannel` to create a clip of a live broadcast
|
- `TwitchChannel` to create a clip of a live broadcast
|
||||||
|
|
||||||
### Get Channel
|
### Get Channel
|
||||||
|
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#get-channel-information
|
URL: https://dev.twitch.tv/docs/api/reference#get-channel-information
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp getChannel`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `TwitchChannel` to refresh stream title
|
- `TwitchChannel` to refresh stream title
|
||||||
|
|
||||||
### Update Channel
|
### Update Channel
|
||||||
|
@ -69,8 +56,8 @@ URL: https://dev.twitch.tv/docs/api/reference#get-channel-information
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#modify-channel-information
|
URL: https://dev.twitch.tv/docs/api/reference#modify-channel-information
|
||||||
Requires `channel:manage:broadcast` scope
|
Requires `channel:manage:broadcast` scope
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp updateChannel`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `/setgame` to update the game in the current channel
|
- `/setgame` to update the game in the current channel
|
||||||
- `/settitle` to update the title in the current channel
|
- `/settitle` to update the title in the current channel
|
||||||
|
|
||||||
|
@ -79,8 +66,8 @@ Requires `channel:manage:broadcast` scope
|
||||||
URL: https://dev.twitch.tv/docs/api/reference/#create-stream-marker
|
URL: https://dev.twitch.tv/docs/api/reference/#create-stream-marker
|
||||||
Requires `user:edit:broadcast` scope
|
Requires `user:edit:broadcast` scope
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp createStreamMarker`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `controllers/commands/CommandController.cpp` in /marker command
|
- `controllers/commands/CommandController.cpp` in /marker command
|
||||||
|
|
||||||
### Get User Block List
|
### Get User Block List
|
||||||
|
@ -88,8 +75,8 @@ Requires `user:edit:broadcast` scope
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#get-user-block-list
|
URL: https://dev.twitch.tv/docs/api/reference#get-user-block-list
|
||||||
Requires `user:read:blocked_users` scope
|
Requires `user:read:blocked_users` scope
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp loadBlocks`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `providers/twitch/TwitchAccount.cpp loadBlocks` to load list of blocked (blocked) users by current user
|
- `providers/twitch/TwitchAccount.cpp loadBlocks` to load list of blocked (blocked) users by current user
|
||||||
|
|
||||||
### Block User
|
### Block User
|
||||||
|
@ -97,8 +84,8 @@ Requires `user:read:blocked_users` scope
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#block-user
|
URL: https://dev.twitch.tv/docs/api/reference#block-user
|
||||||
Requires `user:manage:blocked_users` scope
|
Requires `user:manage:blocked_users` scope
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp blockUser`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `widgets/dialogs/UserInfoPopup.cpp` to block a user via checkbox in the usercard
|
- `widgets/dialogs/UserInfoPopup.cpp` to block a user via checkbox in the usercard
|
||||||
- `controllers/commands/CommandController.cpp` to block a user via "/block" command
|
- `controllers/commands/CommandController.cpp` to block a user via "/block" command
|
||||||
|
|
||||||
|
@ -107,8 +94,8 @@ Requires `user:manage:blocked_users` scope
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#unblock-user
|
URL: https://dev.twitch.tv/docs/api/reference#unblock-user
|
||||||
Requires `user:manage:blocked_users` scope
|
Requires `user:manage:blocked_users` scope
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp unblockUser`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `widgets/dialogs/UserInfoPopup.cpp` to unblock a user via checkbox in the usercard
|
- `widgets/dialogs/UserInfoPopup.cpp` to unblock a user via checkbox in the usercard
|
||||||
- `controllers/commands/CommandController.cpp` to unblock a user via "/unblock" command
|
- `controllers/commands/CommandController.cpp` to unblock a user via "/unblock" command
|
||||||
|
|
||||||
|
@ -116,8 +103,8 @@ Requires `user:manage:blocked_users` scope
|
||||||
|
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#search-categories
|
URL: https://dev.twitch.tv/docs/api/reference#search-categories
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp searchGames`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `controllers/commands/CommandController.cpp` in `/setgame` command to fuzzy search for game titles
|
- `controllers/commands/CommandController.cpp` in `/setgame` command to fuzzy search for game titles
|
||||||
|
|
||||||
### Manage Held AutoMod Messages
|
### Manage Held AutoMod Messages
|
||||||
|
@ -125,31 +112,28 @@ URL: https://dev.twitch.tv/docs/api/reference#search-categories
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#manage-held-automod-messages
|
URL: https://dev.twitch.tv/docs/api/reference#manage-held-automod-messages
|
||||||
Requires `moderator:manage:automod` scope
|
Requires `moderator:manage:automod` scope
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp manageAutoModMessages`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `providers/twitch/TwitchAccount.cpp` to approve/deny held AutoMod messages
|
- `providers/twitch/TwitchAccount.cpp` to approve/deny held AutoMod messages
|
||||||
|
|
||||||
### Get Cheermotes
|
### Get Cheermotes
|
||||||
|
|
||||||
URL: https://dev.twitch.tv/docs/api/reference/#get-cheermotes
|
URL: https://dev.twitch.tv/docs/api/reference/#get-cheermotes
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp getCheermotes`
|
|
||||||
Used in:
|
Used in:
|
||||||
|
|
||||||
- `providers/twitch/TwitchChannel.cpp` to resolve a chats available cheer emotes. This helps us parse incoming messages like `pajaCheer1000`
|
- `providers/twitch/TwitchChannel.cpp` to resolve a chats available cheer emotes. This helps us parse incoming messages like `pajaCheer1000`
|
||||||
|
|
||||||
### Get Emote Sets
|
### Get Emote Sets
|
||||||
|
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#get-emote-sets
|
URL: https://dev.twitch.tv/docs/api/reference#get-emote-sets
|
||||||
|
|
||||||
- We implement this in `providers/twitch/api/Helix.cpp getEmoteSetData`
|
Not used anywhere at the moment. Could be useful in the future for loading emotes from Helix.
|
||||||
Used in:
|
|
||||||
- `providers/twitch/TwitchAccount.cpp` to set emoteset owner data upon loading subscriber emotes from Kraken
|
|
||||||
|
|
||||||
### Get Channel Emotes
|
### Get Channel Emotes
|
||||||
|
|
||||||
URL: https://dev.twitch.tv/docs/api/reference#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.
|
Not used anywhere at the moment.
|
||||||
|
|
||||||
## TMI
|
## TMI
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
#include "providers/twitch/api/Kraken.hpp"
|
|
||||||
#include "singletons/Resources.hpp"
|
#include "singletons/Resources.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
|
|
Loading…
Reference in a new issue