Add /setgame and /settitle (#2534)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -578,6 +578,48 @@ void Helix::unblockUser(QString targetUserId,
|
||||
.execute();
|
||||
}
|
||||
|
||||
void Helix::updateChannel(QString broadcasterId, QString gameId,
|
||||
QString language, QString title,
|
||||
std::function<void(NetworkResult)> successCallback,
|
||||
HelixFailureCallback failureCallback)
|
||||
{
|
||||
QUrlQuery urlQuery;
|
||||
auto data = QJsonDocument();
|
||||
auto obj = QJsonObject();
|
||||
if (!gameId.isEmpty())
|
||||
{
|
||||
obj.insert("game_id", gameId);
|
||||
}
|
||||
if (!language.isEmpty())
|
||||
{
|
||||
obj.insert("broadcaster_language", language);
|
||||
}
|
||||
if (!title.isEmpty())
|
||||
{
|
||||
obj.insert("title", title);
|
||||
}
|
||||
|
||||
if (title.isEmpty() && gameId.isEmpty() && language.isEmpty())
|
||||
{
|
||||
qCDebug(chatterinoCommon) << "Tried to update channel with no changes!";
|
||||
return;
|
||||
}
|
||||
|
||||
data.setObject(obj);
|
||||
urlQuery.addQueryItem("broadcaster_id", broadcasterId);
|
||||
this->makeRequest("channels", urlQuery)
|
||||
.type(NetworkRequestType::Patch)
|
||||
.header("Content-Type", "application/json")
|
||||
.payload(data.toJson())
|
||||
.onSuccess([successCallback, failureCallback](auto result) -> Outcome {
|
||||
successCallback(result);
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](NetworkResult result) {
|
||||
failureCallback();
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
NetworkRequest Helix::makeRequest(QString url, QUrlQuery urlQuery)
|
||||
{
|
||||
assert(!url.startsWith("/"));
|
||||
|
||||
@@ -296,6 +296,12 @@ public:
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback);
|
||||
|
||||
// https://dev.twitch.tv/docs/api/reference#modify-channel-information
|
||||
void updateChannel(QString broadcasterId, QString gameId, QString language,
|
||||
QString title,
|
||||
std::function<void(NetworkResult)> successCallback,
|
||||
HelixFailureCallback failureCallback);
|
||||
|
||||
void update(QString clientId, QString oauthToken);
|
||||
|
||||
static void initialize();
|
||||
|
||||
@@ -104,6 +104,16 @@ URL: https://dev.twitch.tv/docs/api/reference#get-channel-information
|
||||
Used in:
|
||||
- `TwitchChannel` to refresh stream title
|
||||
|
||||
### Update Channel
|
||||
|
||||
URL: https://dev.twitch.tv/docs/api/reference#modify-channel-information
|
||||
Requires `channel:manage:broadcast` scope
|
||||
|
||||
- We implement this in `providers/twitch/api/Helix.cpp updateChannel`
|
||||
Used in:
|
||||
- `/setgame` to update the game in the current channel
|
||||
- `/settitle` to update the title in the current channel
|
||||
|
||||
### Create Stream Marker
|
||||
|
||||
URL: https://dev.twitch.tv/docs/api/reference/#create-stream-marker
|
||||
|
||||
Reference in New Issue
Block a user