Skip to content
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

Fix built-in commands not working in special channels #3288

Merged
merged 6 commits into from
Oct 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions src/controllers/commands/CommandController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TwitchChannel *>(channel.get());
if (twitchChannel == nullptr)
{
channel->addMessage(makeSystemMessage(
"The /marker command only works in Twitch channels"));
return "";
}

Mm2PL marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -626,8 +629,6 @@ void CommandController::initialize(Settings &, Paths &paths)
return "";
}

auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());

// Exact same message as in webchat
if (!twitchChannel->isLive())
{
Expand Down Expand Up @@ -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);
Expand Down