New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate /mods command to helix API #4103
Conversation
@pajlada I tried to follow the same paradigm as your changes to the /chatters api request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
This PR can get The related code to copy can be found in the |
@Felanbird I added the timegate logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things I noticed:
-
Clickable/colorized names have been regressed.
https://github.com/Chatterino/chatterino2/pull/3187/files was the original implementation -
Response should be sorted alphabetically
-
needs a test in
tests/src/HighlightController.cpp
example from /vips:
// /vips
// The extra parenthesis around the failure callback is because its type contains a comma
MOCK_METHOD(
void, getChannelVIPs,
(QString broadcasterID,
ResultCallback<std::vector<HelixVip>> successCallback,
(FailureCallback<HelixListVIPsError, QString> failureCallback)),
(override)); // /vips
@Felanbird All items from your previous comment should be fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality works as expected 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've chosen a limit of 500, but this could be updated if necessary in the future
…st (max 100 as per helix docs)
You followed the paradigm really well, and it turns out my implementation actually didn't work! I made it work now for sure, and I'll make a PR later to fix the Chatters command too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
@@ -1657,6 +1657,62 @@ void TwitchMessageBuilder::listOfUsersSystemMessage(QString prefix, | |||
} | |||
} | |||
|
|||
void TwitchMessageBuilder::listOfUsersSystemMessage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'listOfUsersSystemMessage' can be made static [readability-convert-member-functions-to-static]
void TwitchMessageBuilder::listOfUsersSystemMessage( | |
}static |
@@ -1657,6 +1657,62 @@ | |||
} | |||
} | |||
|
|||
void TwitchMessageBuilder::listOfUsersSystemMessage( | |||
QString prefix, const std::vector<HelixModerator> &users, Channel *channel, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the parameter 'prefix' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
QString prefix, const std::vector<HelixModerator> &users, Channel *channel, | |
sage(const & |
@@ -1657,6 +1657,62 @@ | |||
} | |||
} | |||
|
|||
void TwitchMessageBuilder::listOfUsersSystemMessage( | |||
QString prefix, const std::vector<HelixModerator> &users, Channel *channel, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: parameter 'users' is unused [misc-unused-parameters]
QString prefix, const std::vector<HelixModerator> &users, Channel *channel, | |
sage( /*users*/ |
|
||
using namespace chatterino; | ||
|
||
static constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: 'NUM_MODERATORS_TO_FETCH_PER_REQUEST' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
static constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100; | |
constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100; |
@@ -1859,6 +1867,115 @@ | |||
.execute(); | |||
} | |||
|
|||
void Helix::onFetchModeratorsSuccess( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'onFetchModeratorsSuccess' can be made static [readability-convert-member-functions-to-static]
void Helix::onFetchModeratorsSuccess( | |
static void Helix::onFetchModeratorsSuccess( |
|
||
// https://dev.twitch.tv/docs/api/reference#get-moderators | ||
void Helix::fetchModerators( | ||
QString broadcasterID, int first, QString after, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the parameter 'broadcasterID' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
QString broadcasterID, int first, QString after, | |
const QString& broadcasterID, int first, QString after, |
|
||
// https://dev.twitch.tv/docs/api/reference#get-moderators | ||
void Helix::fetchModerators( | ||
QString broadcasterID, int first, QString after, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the parameter 'after' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
QString broadcasterID, int first, QString after, | |
QString broadcasterID, int first, const QString& after, |
case 401: { | ||
if (message.startsWith("Missing scope", | ||
Qt::CaseInsensitive)) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: repeated branch in conditional chain [bugprone-branch-clone]
{
^
src/providers/twitch/api/Helix.cpp:1949: end of the original
}
^
src/providers/twitch/api/Helix.cpp:1951: clone 1 starts here
{
^
src/providers/twitch/api/Helix.cpp:1955: clone 2 starts here
{
^
@@ -2106,6 +2223,25 @@ | |||
fetchSuccess(fetchSuccess), failureCallback); | |||
} | |||
|
|||
// https://dev.twitch.tv/docs/api/reference#get-moderators | |||
void Helix::getModerators( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'getModerators' can be made static [readability-convert-member-functions-to-static]
void Helix::getModerators( | |
static void Helix::getModerators( |
@@ -2106,6 +2223,25 @@ | |||
fetchSuccess(fetchSuccess), failureCallback); | |||
} | |||
|
|||
// https://dev.twitch.tv/docs/api/reference#get-moderators | |||
void Helix::getModerators( | |||
QString broadcasterID, int maxModeratorsToFetch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the parameter 'broadcasterID' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
QString broadcasterID, int maxModeratorsToFetch, | |
const QString& broadcasterID, int maxModeratorsToFetch, |
Pull request checklist:
closes #3971
CHANGELOG.md
was updated, if applicableDescription
Modeled after the /chatters migration PR #4088.
/mods command no longer uses the irc command and now makes a helix api request.
mod list is paginated just like chatter list.