Allow for usage of builtin Chatterino commands in custom commands. (#2632)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL 2021-04-17 10:33:18 +00:00 committed by GitHub
parent 8641435142
commit 3ee23b2bae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 9 deletions

View file

@ -2,6 +2,7 @@
## Unversioned ## Unversioned
- Minor: Allow for built-in Chatterino commands to be used in custom commands. (#2632)
- Bugfix: Fix crash that could occur when the user changed the "Custom stream player URI Scheme" setting if the user had closed down and splits in the application runtime. (#2592) - Bugfix: Fix crash that could occur when the user changed the "Custom stream player URI Scheme" setting if the user had closed down and splits in the application runtime. (#2592)
## 2.3.0 ## 2.3.0

View file

@ -769,6 +769,25 @@ QString CommandController::execCommand(const QString &textNoEmoji,
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()); auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
{
// check if user command exists
const auto it = this->userCommands_.find(commandName);
if (it != this->userCommands_.end())
{
text = getApp()->emotes->emojis.replaceShortCodes(
this->execCustomCommand(words, it.value(), dryRun));
words = text.split(' ', QString::SkipEmptyParts);
if (words.length() == 0)
{
return text;
}
commandName = words[0];
}
}
// works only in a valid twitch channel // works only in a valid twitch channel
if (!dryRun && twitchChannel != nullptr) if (!dryRun && twitchChannel != nullptr)
{ {
@ -780,15 +799,6 @@ QString CommandController::execCommand(const QString &textNoEmoji,
} }
} }
{
// check if user command exists
const auto it = this->userCommands_.find(commandName);
if (it != this->userCommands_.end())
{
return this->execCustomCommand(words, it.value(), dryRun);
}
}
auto maxSpaces = std::min(this->maxSpaces_, words.length() - 1); auto maxSpaces = std::min(this->maxSpaces_, words.length() - 1);
for (int i = 0; i < maxSpaces; ++i) for (int i = 0; i < maxSpaces; ++i)
{ {