Migrate /mods command to helix API (#4103)
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -71,6 +71,7 @@
|
|||||||
- Minor: Added stream titles to windows live toast notifications. (#1297)
|
- Minor: Added stream titles to windows live toast notifications. (#1297)
|
||||||
- Minor: Make menus and placeholders display appropriate custom key combos. (#4045)
|
- Minor: Make menus and placeholders display appropriate custom key combos. (#4045)
|
||||||
- Minor: Migrated /chatters to Helix API. (#4088, #4097)
|
- Minor: Migrated /chatters to Helix API. (#4088, #4097)
|
||||||
|
- Minor: Migrated /mods to Helix API. (#4103)
|
||||||
- Minor: Add settings tooltips. (#3437)
|
- Minor: Add settings tooltips. (#3437)
|
||||||
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)
|
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)
|
||||||
- Bugfix: Fixed `Smooth scrolling on new messages` setting sometimes hiding messages. (#4028)
|
- Bugfix: Fixed `Smooth scrolling on new messages` setting sometimes hiding messages. (#4028)
|
||||||
|
|||||||
@@ -938,6 +938,91 @@ void CommandController::initialize(Settings &, Paths &paths)
|
|||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
auto formatModsError = [](HelixGetModeratorsError error, QString message) {
|
||||||
|
using Error = HelixGetModeratorsError;
|
||||||
|
|
||||||
|
QString errorMessage = QString("Failed to get moderators: ");
|
||||||
|
|
||||||
|
switch (error)
|
||||||
|
{
|
||||||
|
case Error::Forwarded: {
|
||||||
|
errorMessage += message;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Error::UserMissingScope: {
|
||||||
|
errorMessage += "Missing required scope. "
|
||||||
|
"Re-login with your "
|
||||||
|
"account and try again.";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Error::UserNotAuthorized: {
|
||||||
|
errorMessage +=
|
||||||
|
"Due to Twitch restrictions, "
|
||||||
|
"this command can only be used by the broadcaster. "
|
||||||
|
"To see the list of mods you must use the Twitch website.";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Error::Unknown: {
|
||||||
|
errorMessage += "An unknown error has occurred.";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return errorMessage;
|
||||||
|
};
|
||||||
|
|
||||||
|
this->registerCommand(
|
||||||
|
"/mods",
|
||||||
|
[formatModsError](const QStringList &words, auto channel) -> QString {
|
||||||
|
switch (getSettings()->helixTimegateModerators.getValue())
|
||||||
|
{
|
||||||
|
case HelixTimegateOverride::Timegate: {
|
||||||
|
if (areIRCCommandsStillAvailable())
|
||||||
|
{
|
||||||
|
return useIRCCommand(words);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HelixTimegateOverride::AlwaysUseIRC: {
|
||||||
|
return useIRCCommand(words);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HelixTimegateOverride::AlwaysUseHelix: {
|
||||||
|
// Fall through to helix logic
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||||
|
|
||||||
|
if (twitchChannel == nullptr)
|
||||||
|
{
|
||||||
|
channel->addMessage(makeSystemMessage(
|
||||||
|
"The /mods command only works in Twitch Channels"));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
getHelix()->getModerators(
|
||||||
|
twitchChannel->roomId(), 500,
|
||||||
|
[channel, twitchChannel](auto result) {
|
||||||
|
// TODO: sort results?
|
||||||
|
|
||||||
|
MessageBuilder builder;
|
||||||
|
TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||||
|
"The moderators of this channel are", result,
|
||||||
|
twitchChannel, &builder);
|
||||||
|
channel->addMessage(builder.release());
|
||||||
|
},
|
||||||
|
[channel, formatModsError](auto error, auto message) {
|
||||||
|
auto errorMessage = formatModsError(error, message);
|
||||||
|
channel->addMessage(makeSystemMessage(errorMessage));
|
||||||
|
});
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
|
||||||
this->registerCommand("/clip", [](const auto & /*words*/, auto channel) {
|
this->registerCommand("/clip", [](const auto & /*words*/, auto channel) {
|
||||||
if (const auto type = channel->getType();
|
if (const auto type = channel->getType();
|
||||||
type != Channel::Type::Twitch &&
|
type != Channel::Type::Twitch &&
|
||||||
|
|||||||
@@ -1657,6 +1657,62 @@ void TwitchMessageBuilder::listOfUsersSystemMessage(QString prefix,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||||
|
QString prefix, const std::vector<HelixModerator> &users, Channel *channel,
|
||||||
|
MessageBuilder *builder)
|
||||||
|
{
|
||||||
|
QString text = prefix;
|
||||||
|
|
||||||
|
builder->emplace<TimestampElement>();
|
||||||
|
builder->message().flags.set(MessageFlag::System);
|
||||||
|
builder->message().flags.set(MessageFlag::DoNotTriggerNotification);
|
||||||
|
builder->emplace<TextElement>(prefix, MessageElementFlag::Text,
|
||||||
|
MessageColor::System);
|
||||||
|
bool isFirst = true;
|
||||||
|
auto *tc = dynamic_cast<TwitchChannel *>(channel);
|
||||||
|
for (const auto &user : users)
|
||||||
|
{
|
||||||
|
if (!isFirst)
|
||||||
|
{
|
||||||
|
// this is used to add the ", " after each but the last entry
|
||||||
|
builder->emplace<TextElement>(",", MessageElementFlag::Text,
|
||||||
|
MessageColor::System);
|
||||||
|
text += QString(", %1").arg(user.userName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text += user.userName;
|
||||||
|
}
|
||||||
|
isFirst = false;
|
||||||
|
|
||||||
|
MessageColor color = MessageColor::System;
|
||||||
|
|
||||||
|
if (tc && getSettings()->colorUsernames)
|
||||||
|
{
|
||||||
|
if (auto userColor = tc->getUserColor(user.userLogin);
|
||||||
|
userColor.isValid())
|
||||||
|
{
|
||||||
|
color = MessageColor(userColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder
|
||||||
|
->emplace<TextElement>(user.userName,
|
||||||
|
MessageElementFlag::BoldUsername, color,
|
||||||
|
FontStyle::ChatMediumBold)
|
||||||
|
->setLink({Link::UserInfo, user.userLogin})
|
||||||
|
->setTrailingSpace(false);
|
||||||
|
builder
|
||||||
|
->emplace<TextElement>(user.userName,
|
||||||
|
MessageElementFlag::NonBoldUsername, color)
|
||||||
|
->setLink({Link::UserInfo, user.userLogin})
|
||||||
|
->setTrailingSpace(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder->message().messageText = text;
|
||||||
|
builder->message().searchText = text;
|
||||||
|
}
|
||||||
|
|
||||||
void TwitchMessageBuilder::setThread(std::shared_ptr<MessageThread> thread)
|
void TwitchMessageBuilder::setThread(std::shared_ptr<MessageThread> thread)
|
||||||
{
|
{
|
||||||
this->thread_ = std::move(thread);
|
this->thread_ = std::move(thread);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "providers/twitch/ChannelPointReward.hpp"
|
#include "providers/twitch/ChannelPointReward.hpp"
|
||||||
#include "providers/twitch/PubSubActions.hpp"
|
#include "providers/twitch/PubSubActions.hpp"
|
||||||
#include "providers/twitch/TwitchBadge.hpp"
|
#include "providers/twitch/TwitchBadge.hpp"
|
||||||
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
|
|
||||||
#include <IrcMessage>
|
#include <IrcMessage>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -77,6 +78,9 @@ public:
|
|||||||
static void listOfUsersSystemMessage(QString prefix, QStringList users,
|
static void listOfUsersSystemMessage(QString prefix, QStringList users,
|
||||||
Channel *channel,
|
Channel *channel,
|
||||||
MessageBuilder *builder);
|
MessageBuilder *builder);
|
||||||
|
static void listOfUsersSystemMessage(
|
||||||
|
QString prefix, const std::vector<HelixModerator> &users,
|
||||||
|
Channel *channel, MessageBuilder *builder);
|
||||||
|
|
||||||
// Shares some common logic from SharedMessageBuilder::parseBadgeTag
|
// Shares some common logic from SharedMessageBuilder::parseBadgeTag
|
||||||
static std::unordered_map<QString, QString> parseBadgeInfoTag(
|
static std::unordered_map<QString, QString> parseBadgeInfoTag(
|
||||||
|
|||||||
@@ -6,6 +6,14 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using namespace chatterino;
|
||||||
|
|
||||||
|
static constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
static IHelix *instance = nullptr;
|
static IHelix *instance = nullptr;
|
||||||
@@ -1859,6 +1867,115 @@ void Helix::fetchChatters(
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Helix::onFetchModeratorsSuccess(
|
||||||
|
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
||||||
|
QString broadcasterID, int maxModeratorsToFetch,
|
||||||
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
||||||
|
HelixModerators moderators)
|
||||||
|
{
|
||||||
|
qCDebug(chatterinoTwitch)
|
||||||
|
<< "Fetched " << moderators.moderators.size() << " moderators";
|
||||||
|
|
||||||
|
std::for_each(moderators.moderators.begin(), moderators.moderators.end(),
|
||||||
|
[finalModerators](auto mod) {
|
||||||
|
finalModerators->push_back(mod);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (moderators.cursor.isEmpty() ||
|
||||||
|
finalModerators->size() >= maxModeratorsToFetch)
|
||||||
|
{
|
||||||
|
// Done paginating
|
||||||
|
successCallback(*finalModerators);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->fetchModerators(
|
||||||
|
broadcasterID, NUM_MODERATORS_TO_FETCH_PER_REQUEST, moderators.cursor,
|
||||||
|
[=](auto moderators) {
|
||||||
|
this->onFetchModeratorsSuccess(
|
||||||
|
finalModerators, broadcasterID, maxModeratorsToFetch,
|
||||||
|
successCallback, failureCallback, moderators);
|
||||||
|
},
|
||||||
|
failureCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://dev.twitch.tv/docs/api/reference#get-moderators
|
||||||
|
void Helix::fetchModerators(
|
||||||
|
QString broadcasterID, int first, QString after,
|
||||||
|
ResultCallback<HelixModerators> successCallback,
|
||||||
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback)
|
||||||
|
{
|
||||||
|
using Error = HelixGetModeratorsError;
|
||||||
|
|
||||||
|
QUrlQuery urlQuery;
|
||||||
|
|
||||||
|
urlQuery.addQueryItem("broadcaster_id", broadcasterID);
|
||||||
|
urlQuery.addQueryItem("first", QString::number(first));
|
||||||
|
|
||||||
|
if (!after.isEmpty())
|
||||||
|
{
|
||||||
|
urlQuery.addQueryItem("after", after);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->makeRequest("moderation/moderators", urlQuery)
|
||||||
|
.onSuccess([successCallback](auto result) -> Outcome {
|
||||||
|
if (result.status() != 200)
|
||||||
|
{
|
||||||
|
qCWarning(chatterinoTwitch)
|
||||||
|
<< "Success result for getting moderators was "
|
||||||
|
<< result.status() << "but we expected it to be 200";
|
||||||
|
}
|
||||||
|
|
||||||
|
auto response = result.parseJson();
|
||||||
|
successCallback(HelixModerators(response));
|
||||||
|
return Success;
|
||||||
|
})
|
||||||
|
.onError([failureCallback](auto result) {
|
||||||
|
auto obj = result.parseJson();
|
||||||
|
auto message = obj.value("message").toString();
|
||||||
|
|
||||||
|
switch (result.status())
|
||||||
|
{
|
||||||
|
case 400: {
|
||||||
|
failureCallback(Error::Forwarded, message);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 401: {
|
||||||
|
if (message.startsWith("Missing scope",
|
||||||
|
Qt::CaseInsensitive))
|
||||||
|
{
|
||||||
|
failureCallback(Error::UserMissingScope, message);
|
||||||
|
}
|
||||||
|
else if (message.contains("OAuth token"))
|
||||||
|
{
|
||||||
|
failureCallback(Error::UserNotAuthorized, message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
failureCallback(Error::Forwarded, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 403: {
|
||||||
|
failureCallback(Error::UserNotAuthorized, message);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: {
|
||||||
|
qCDebug(chatterinoTwitch)
|
||||||
|
<< "Unhandled error data:" << result.status()
|
||||||
|
<< result.getData() << obj;
|
||||||
|
failureCallback(Error::Unknown, message);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
// Ban/timeout a user
|
// Ban/timeout a user
|
||||||
// https://dev.twitch.tv/docs/api/reference#ban-user
|
// https://dev.twitch.tv/docs/api/reference#ban-user
|
||||||
void Helix::banUser(QString broadcasterID, QString moderatorID, QString userID,
|
void Helix::banUser(QString broadcasterID, QString moderatorID, QString userID,
|
||||||
@@ -2106,6 +2223,25 @@ void Helix::getChatters(
|
|||||||
fetchSuccess(fetchSuccess), failureCallback);
|
fetchSuccess(fetchSuccess), failureCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dev.twitch.tv/docs/api/reference#get-moderators
|
||||||
|
void Helix::getModerators(
|
||||||
|
QString broadcasterID, int maxModeratorsToFetch,
|
||||||
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback)
|
||||||
|
{
|
||||||
|
auto finalModerators = std::make_shared<std::vector<HelixModerator>>();
|
||||||
|
|
||||||
|
// Initiate the recursive calls
|
||||||
|
this->fetchModerators(
|
||||||
|
broadcasterID, NUM_MODERATORS_TO_FETCH_PER_REQUEST, "",
|
||||||
|
[=](auto moderators) {
|
||||||
|
this->onFetchModeratorsSuccess(
|
||||||
|
finalModerators, broadcasterID, maxModeratorsToFetch,
|
||||||
|
successCallback, failureCallback, moderators);
|
||||||
|
},
|
||||||
|
failureCallback);
|
||||||
|
}
|
||||||
|
|
||||||
// List the VIPs of a channel
|
// List the VIPs of a channel
|
||||||
// https://dev.twitch.tv/docs/api/reference#get-vips
|
// https://dev.twitch.tv/docs/api/reference#get-vips
|
||||||
void Helix::getChannelVIPs(
|
void Helix::getChannelVIPs(
|
||||||
|
|||||||
@@ -332,8 +332,13 @@ struct HelixChatSettings {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct HelixVip {
|
struct HelixVip {
|
||||||
|
// Twitch ID of the user
|
||||||
QString userId;
|
QString userId;
|
||||||
|
|
||||||
|
// Display name of the user
|
||||||
QString userName;
|
QString userName;
|
||||||
|
|
||||||
|
// Login name of the user
|
||||||
QString userLogin;
|
QString userLogin;
|
||||||
|
|
||||||
explicit HelixVip(const QJsonObject &jsonObject)
|
explicit HelixVip(const QJsonObject &jsonObject)
|
||||||
@@ -367,9 +372,29 @@ struct HelixChatters {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(jammehcow): when implementing mod list, just alias HelixVip to HelixMod
|
using HelixModerator = HelixVip;
|
||||||
// as they share the same model.
|
|
||||||
// Alternatively, rename base struct to HelixUser or something and alias both
|
struct HelixModerators {
|
||||||
|
std::vector<HelixModerator> moderators;
|
||||||
|
QString cursor;
|
||||||
|
|
||||||
|
HelixModerators() = default;
|
||||||
|
|
||||||
|
explicit HelixModerators(const QJsonObject &jsonObject)
|
||||||
|
: cursor(jsonObject.value("pagination")
|
||||||
|
.toObject()
|
||||||
|
.value("cursor")
|
||||||
|
.toString())
|
||||||
|
{
|
||||||
|
const auto &data = jsonObject.value("data").toArray();
|
||||||
|
for (const auto &mod : data)
|
||||||
|
{
|
||||||
|
HelixModerator moderator(mod.toObject());
|
||||||
|
|
||||||
|
this->moderators.push_back(moderator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
enum class HelixAnnouncementColor {
|
enum class HelixAnnouncementColor {
|
||||||
Blue,
|
Blue,
|
||||||
@@ -553,6 +578,15 @@ enum class HelixGetChattersError {
|
|||||||
Forwarded,
|
Forwarded,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class HelixGetModeratorsError {
|
||||||
|
Unknown,
|
||||||
|
UserMissingScope,
|
||||||
|
UserNotAuthorized,
|
||||||
|
|
||||||
|
// The error message is forwarded directly from the Twitch API
|
||||||
|
Forwarded,
|
||||||
|
};
|
||||||
|
|
||||||
enum class HelixListVIPsError { // /vips
|
enum class HelixListVIPsError { // /vips
|
||||||
Unknown,
|
Unknown,
|
||||||
UserMissingScope,
|
UserMissingScope,
|
||||||
@@ -854,6 +888,14 @@ public:
|
|||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback) = 0;
|
FailureCallback<HelixGetChattersError, QString> failureCallback) = 0;
|
||||||
|
|
||||||
|
// Get moderators from the `broadcasterID` channel
|
||||||
|
// This will follow the returned cursor
|
||||||
|
// https://dev.twitch.tv/docs/api/reference#get-moderators
|
||||||
|
virtual void getModerators(
|
||||||
|
QString broadcasterID, int maxModeratorsToFetch,
|
||||||
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback) = 0;
|
||||||
|
|
||||||
// https://dev.twitch.tv/docs/api/reference#get-vips
|
// https://dev.twitch.tv/docs/api/reference#get-vips
|
||||||
virtual void getChannelVIPs(
|
virtual void getChannelVIPs(
|
||||||
QString broadcasterID,
|
QString broadcasterID,
|
||||||
@@ -1130,6 +1172,15 @@ public:
|
|||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback) final;
|
FailureCallback<HelixGetChattersError, QString> failureCallback) final;
|
||||||
|
|
||||||
|
// Get moderators from the `broadcasterID` channel
|
||||||
|
// This will follow the returned cursor
|
||||||
|
// https://dev.twitch.tv/docs/api/reference#get-moderators
|
||||||
|
void getModerators(
|
||||||
|
QString broadcasterID, int maxModeratorsToFetch,
|
||||||
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback)
|
||||||
|
final;
|
||||||
|
|
||||||
// https://dev.twitch.tv/docs/api/reference#get-vips
|
// https://dev.twitch.tv/docs/api/reference#get-vips
|
||||||
void getChannelVIPs(
|
void getChannelVIPs(
|
||||||
QString broadcasterID,
|
QString broadcasterID,
|
||||||
@@ -1162,6 +1213,21 @@ protected:
|
|||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback);
|
FailureCallback<HelixGetChattersError, QString> failureCallback);
|
||||||
|
|
||||||
|
// Recursive boy
|
||||||
|
void onFetchModeratorsSuccess(
|
||||||
|
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
||||||
|
QString broadcasterID, int maxModeratorsToFetch,
|
||||||
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
||||||
|
HelixModerators moderators);
|
||||||
|
|
||||||
|
// Get moderator list - This method is what actually runs the API request
|
||||||
|
// https://dev.twitch.tv/docs/api/reference#get-moderators
|
||||||
|
void fetchModerators(
|
||||||
|
QString broadcasterID, int first, QString after,
|
||||||
|
ResultCallback<HelixModerators> successCallback,
|
||||||
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetworkRequest makeRequest(QString url, QUrlQuery urlQuery);
|
NetworkRequest makeRequest(QString url, QUrlQuery urlQuery);
|
||||||
|
|
||||||
|
|||||||
@@ -442,6 +442,10 @@ public:
|
|||||||
"/misc/twitch/helix-timegate/vips",
|
"/misc/twitch/helix-timegate/vips",
|
||||||
HelixTimegateOverride::Timegate,
|
HelixTimegateOverride::Timegate,
|
||||||
};
|
};
|
||||||
|
EnumSetting<HelixTimegateOverride> helixTimegateModerators = {
|
||||||
|
"/misc/twitch/helix-timegate/moderators",
|
||||||
|
HelixTimegateOverride::Timegate,
|
||||||
|
};
|
||||||
|
|
||||||
EnumSetting<HelixTimegateOverride> helixTimegateCommercial = {
|
EnumSetting<HelixTimegateOverride> helixTimegateCommercial = {
|
||||||
"/misc/twitch/helix-timegate/commercial",
|
"/misc/twitch/helix-timegate/commercial",
|
||||||
|
|||||||
@@ -866,6 +866,17 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
|||||||
helixTimegateCommercial->setMinimumWidth(
|
helixTimegateCommercial->setMinimumWidth(
|
||||||
helixTimegateCommercial->minimumSizeHint().width());
|
helixTimegateCommercial->minimumSizeHint().width());
|
||||||
|
|
||||||
|
auto *helixTimegateModerators =
|
||||||
|
layout.addDropdown<std::underlying_type<HelixTimegateOverride>::type>(
|
||||||
|
"Helix timegate /mods behaviour",
|
||||||
|
{"Timegate", "Always use IRC", "Always use Helix"},
|
||||||
|
s.helixTimegateModerators,
|
||||||
|
helixTimegateGetValue, //
|
||||||
|
helixTimegateSetValue, //
|
||||||
|
false);
|
||||||
|
helixTimegateModerators->setMinimumWidth(
|
||||||
|
helixTimegateModerators->minimumSizeHint().width());
|
||||||
|
|
||||||
layout.addStretch();
|
layout.addStretch();
|
||||||
|
|
||||||
// invisible element for width
|
// invisible element for width
|
||||||
|
|||||||
@@ -391,6 +391,15 @@ public:
|
|||||||
(FailureCallback<HelixStartCommercialError, QString> failureCallback)),
|
(FailureCallback<HelixStartCommercialError, QString> failureCallback)),
|
||||||
(override)); // /commercial
|
(override)); // /commercial
|
||||||
|
|
||||||
|
// /mods
|
||||||
|
// The extra parenthesis around the failure callback is because its type contains a comma
|
||||||
|
MOCK_METHOD(
|
||||||
|
void, getModerators,
|
||||||
|
(QString broadcasterID, int maxModeratorsToFetch,
|
||||||
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
|
(FailureCallback<HelixGetModeratorsError, QString> failureCallback)),
|
||||||
|
(override)); // /mods
|
||||||
|
|
||||||
MOCK_METHOD(void, update, (QString clientId, QString oauthToken),
|
MOCK_METHOD(void, update, (QString clientId, QString oauthToken),
|
||||||
(override));
|
(override));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user