Repository navigation
feat: allow timeout-related commands to be used in multiple channels - #5402
Conversation
| "from chatting. Reason is optional and will be shown to the target " | ||
| "user and other moderators. Use \"/unban\" to remove a ban."; | ||
| if (words.size() < 2) | ||
| std::vector<PerformChannelAction> actions; |
There was a problem hiding this comment.
warning: variable 'actions' is not initialized [cppcoreguidelines-init-variables]
| std::vector<PerformChannelAction> actions; | |
| std::vector<PerformChannelAction> actions = 0; |
b79ed44 to
2ecb541
Compare
| @@ -1,5 +1,7 @@ | |||
| #pragma once | |||
|
|
|||
| #include "expected.hpp" | |||
There was a problem hiding this comment.
warning: 'expected.hpp' file not found [clang-diagnostic-error]
#include "expected.hpp"
^|
|
||
| } // namespace | ||
|
|
||
| TEST(Commands, parseBanCommand) |
There was a problem hiding this comment.
warning: no header providing "TEST" is directly included [misc-include-cleaner]
tests/src/Commands.cpp:8:
+ #include <gtest/gtest.h>| }; | ||
| auto oActions = commands::parseChannelAction(ctx, "/ban", "usage", false); | ||
|
|
||
| ASSERT_TRUE(oActions.has_value()) << oActions.error(); |
There was a problem hiding this comment.
warning: no header providing "ASSERT_TRUE" is directly included [misc-include-cleaner]
ASSERT_TRUE(oActions.has_value()) << oActions.error();
^|
|
||
| ASSERT_TRUE(oActions.has_value()) << oActions.error(); | ||
| auto actions = *oActions; | ||
| ASSERT_EQ(actions.size(), 1); |
There was a problem hiding this comment.
warning: no header providing "ASSERT_EQ" is directly included [misc-include-cleaner]
ASSERT_EQ(actions.size(), 1);
^|
In your example, you're using raw IDs but in other commands IDs have to be prefixed with Also, are |
|
I'm fine with |
| namespace chatterino::commands { | ||
|
|
||
| QString sendBan(const CommandContext &ctx) | ||
| nonstd::expected<std::vector<PerformChannelAction>, QString> parseChannelAction( |
There was a problem hiding this comment.
warning: no header providing "nonstd::expected_lite::expected" is directly included [misc-include-cleaner]
src/controllers/commands/builtin/twitch/Ban.cpp:7:
- #include "providers/twitch/api/Helix.hpp"
+ #include "nonstd/expected.hpp"
+ #include "providers/twitch/api/Helix.hpp"| namespace chatterino::commands { | ||
|
|
||
| QString sendBan(const CommandContext &ctx) | ||
| nonstd::expected<std::vector<PerformChannelAction>, QString> parseChannelAction( |
There was a problem hiding this comment.
warning: no header providing "std::vector" is directly included [misc-include-cleaner]
src/controllers/commands/builtin/twitch/Ban.cpp:14:
+ #include <vector>| { | ||
| return ""; | ||
| // A ban action must be performed with a channel as a context | ||
| return nonstd::make_unexpected( |
There was a problem hiding this comment.
warning: no header providing "nonstd::expected_lite::make_unexpected" is directly included [misc-include-cleaner]
return nonstd::make_unexpected(
^| } | ||
|
|
||
| if (twitchChannel == nullptr) | ||
| QCommandLineParser parser; |
There was a problem hiding this comment.
warning: no header providing "QCommandLineParser" is directly included [misc-include-cleaner]
src/controllers/commands/builtin/twitch/Ban.cpp:14:
+ #include <qcommandlineparser.h>|
|
||
| } // namespace | ||
|
|
||
| TEST(Commands, parseBanCommand) |
There was a problem hiding this comment.
warning: no header providing "TEST" is directly included [misc-include-cleaner]
tests/src/Commands.cpp:8:
+ #include <gtest/gtest.h>| }; | ||
| auto oActions = commands::parseChannelAction(ctx, "/ban", "usage", false); | ||
|
|
||
| ASSERT_TRUE(oActions.has_value()) << oActions.error(); |
There was a problem hiding this comment.
warning: no header providing "ASSERT_TRUE" is directly included [misc-include-cleaner]
ASSERT_TRUE(oActions.has_value()) << oActions.error();
^|
|
||
| ASSERT_TRUE(oActions.has_value()) << oActions.error(); | ||
| auto actions = *oActions; | ||
| ASSERT_EQ(actions.size(), 1); |
There was a problem hiding this comment.
warning: no header providing "ASSERT_EQ" is directly included [misc-include-cleaner]
ASSERT_EQ(actions.size(), 1);
^example: `/ban --channel 11148817 --channel 117166826 forsen game complainer` this would ban forsen with the reason `game complainer` in the two listed channels
520e12f to
e03c5e8
Compare
| LinkResolver() = default; | ||
| ~LinkResolver() override = default; | ||
|
|
||
| MOCK_METHOD(void, resolve, (LinkInfo * info), (override)); |
There was a problem hiding this comment.
warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]
| MOCK_METHOD(void, resolve, (LinkInfo * info), (override)); | |
| mockMethod(void, resolve, (LinkInfo * info), (override)); |
|
|
||
| namespace chatterino::mock { | ||
|
|
||
| class Logging : public ILogging |
There was a problem hiding this comment.
warning: class 'Logging' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class Logging : public ILogging
^| Logging() = default; | ||
| ~Logging() override = default; | ||
|
|
||
| MOCK_METHOD(void, addMessage, |
There was a problem hiding this comment.
warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]
| MOCK_METHOD(void, addMessage, | |
| mockMethod(void, addMessage, |
| (override)); | ||
| }; | ||
|
|
||
| class EmptyLogging : public ILogging |
There was a problem hiding this comment.
warning: class 'EmptyLogging' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class EmptyLogging : public ILogging
^| class LoggingChannel; | ||
|
|
||
| class Logging | ||
| class ILogging |
There was a problem hiding this comment.
warning: class 'ILogging' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class ILogging
^|
|
||
| using namespace chatterino; | ||
|
|
||
| using ::testing::_; |
There was a problem hiding this comment.
warning: declaration uses identifier '_', which is reserved in the global namespace; cannot be fixed automatically [bugprone-reserved-identifier]
using ::testing::_;
^…hatterino#5402) This changes the behaviour of the following commands: - `/ban` - `/timeout` - `/untimeout` - `/unban` All of those commands now accept one or more `--channel` parameters to override which channel the action should take place in. The `--channel` parameter accepts a channel ID or channel name with the same syntax as the other "user targets" do (e.g. `id:11148817` or `pajlada`) examples Ban user in the chat you're typing in: `/ban weeb123` Ban user in the chat you're typing in, with a reason specified: `/ban weeb123 the ban reason` Ban user in a separate chat, with a reason specified: `/ban --channel pajlada weeb123 the ban reason` Ban user in two separate chats, with a reason specified: `/ban --channel pajlada --channel id:117166826 weeb123 the ban reason` Timeout user in the chat you're typing in: `/timeout weeb123` Timeout user in the chat you're typing in, with a reason specified: `/timeout weeb123 10m the timeout reason` Timeout user in a separate chat, with a reason specified: `/timeout --channel pajlada weeb123 10m the timeout reason` Timeout user in two separate chats, with a reason specified: `/timeout --channel pajlada --channel id:117166826 weeb123 10m the timeout reason` Unban user in the chat you're typing in: `/unban weeb123` Unban user in a separate chat: `/unban --channel pajlada weeb123` Unban user in two separate chats: `/unban --channel pajlada --channel id:117166826 weeb123`

This PR changes the behaviour of the following commands:
/ban/timeout/untimeout/unbanAll of those commands now accept one or more
--channelparameters to override which channel the action should take place in.The
--channelparameter accepts a channel ID or channel name with the same syntax as the other "user targets" do (e.g.id:11148817orpajlada)examples
Ban user in the chat you're typing in:
/ban weeb123Ban user in the chat you're typing in, with a reason specified:
/ban weeb123 the ban reasonBan user in a separate chat, with a reason specified:
/ban --channel pajlada weeb123 the ban reasonBan user in two separate chats, with a reason specified:
/ban --channel pajlada --channel id:117166826 weeb123 the ban reasonTimeout user in the chat you're typing in:
/timeout weeb123Timeout user in the chat you're typing in, with a reason specified:
/timeout weeb123 10m the timeout reasonTimeout user in a separate chat, with a reason specified:
/timeout --channel pajlada weeb123 10m the timeout reasonTimeout user in two separate chats, with a reason specified:
/timeout --channel pajlada --channel id:117166826 weeb123 10m the timeout reasonUnban user in the chat you're typing in:
/unban weeb123Unban user in a separate chat:
/unban --channel pajlada weeb123Unban user in two separate chats:
/unban --channel pajlada --channel id:117166826 weeb123