From c1a3814b7c52e8c1b6956f4eb9297cbe0e407153 Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Sun, 17 Oct 2021 10:45:54 +0000 Subject: [PATCH] Fix built-in commands not working in special channels (#3288) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Co-authored-by: pajlada --- CHANGELOG.md | 1 + src/controllers/commands/CommandController.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a425bd67..b8d6fbb4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - Bugfix: Fixed some channels still not loading in rare cases. (#3219) - Bugfix: Fixed a bug with usernames or emotes completing from the wrong position. (#3229) - Bugfix: Fixed second chatterino icon appearing in the dock when restarting on a crash in macOS. (#3268) +- Bugfix: Fixed built-in Chatterino commands not working in whispers and mentions special channels (#3288) - Bugfix: Fixed `QCharRef with an index pointing outside the valid range of a QString` warning that was emitted on every Tab press. (#3234) - Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103) - Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index cf71b3942..4ed22a4b4 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -613,8 +613,11 @@ void CommandController::initialize(Settings &, Paths &paths) this->registerCommand("/marker", [](const QStringList &words, auto channel) { - if (!channel->isTwitchChannel()) + auto *twitchChannel = dynamic_cast(channel.get()); + if (twitchChannel == nullptr) { + channel->addMessage(makeSystemMessage( + "The /marker command only works in Twitch channels")); return ""; } @@ -626,8 +629,6 @@ void CommandController::initialize(Settings &, Paths &paths) return ""; } - auto *twitchChannel = dynamic_cast(channel.get()); - // Exact same message as in webchat if (!twitchChannel->isLive()) { @@ -935,7 +936,7 @@ QString CommandController::execCommand(const QString &textNoEmoji, } // works only in a valid twitch channel - if (!dryRun && twitchChannel != nullptr) + if (!dryRun && channel->isTwitchChannel()) { // check if command exists const auto it = this->commands_.find(commandName);