feat: allow timeout-related commands to be used in multiple channels (#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 commit is contained in:
pajlada
2024-06-16 12:22:51 +02:00
committed by GitHub
parent 86871eec5a
commit 9b31246502
23 changed files with 1732 additions and 174 deletions
+10 -15
View File
@@ -91,13 +91,6 @@ TwitchChannel::TwitchChannel(const QString &name)
{
qCDebug(chatterinoTwitch) << "[TwitchChannel" << name << "] Opened";
if (!getApp())
{
// This is intended for tests and benchmarks.
// Irc, Pubsub, live-updates, and live-notifications aren't mocked there.
return;
}
this->bSignals_.emplace_back(
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->setMod(false);
@@ -231,13 +224,6 @@ TwitchChannel::TwitchChannel(const QString &name)
TwitchChannel::~TwitchChannel()
{
if (!getApp())
{
// This is for tests and benchmarks, where live-updates aren't mocked
// see comment in constructor.
return;
}
getIApp()->getTwitch()->dropSeventvChannel(this->seventvUserID_,
this->seventvEmoteSetID_);
@@ -586,6 +572,10 @@ void TwitchChannel::showLoginMessage()
void TwitchChannel::roomIdChanged()
{
if (getIApp()->isTest())
{
return;
}
this->refreshPubSub();
this->refreshBadges();
this->refreshCheerEmotes();
@@ -792,7 +782,7 @@ void TwitchChannel::setRoomId(const QString &id)
{
*this->roomID_.access() = id;
// This is intended for tests and benchmarks. See comment in constructor.
if (getApp())
if (!getIApp()->isTest())
{
this->roomIdChanged();
this->loadRecentMessages();
@@ -1341,6 +1331,11 @@ void TwitchChannel::loadRecentMessagesReconnect()
void TwitchChannel::refreshPubSub()
{
if (getIApp()->isTest())
{
return;
}
auto roomId = this->roomId();
if (roomId.isEmpty())
{