Add optional parameter to /usercard command for opening a usercard in a different channel context. (#3172)

Co-authored-by: apa420 <17131426+apa420@users.noreply.github.com>
Co-authored-by: Mm2PL <mm2pl+gh@kotmisia.pl>
Co-authored-by: Leon Richardt <leon.richardt@gmail.com>
This commit is contained in:
LosFarmosCTL
2021-08-21 13:37:57 +02:00
committed by GitHub
parent a7ef7e6f7f
commit 773c4bb9e7
3 changed files with 27 additions and 4 deletions
+22 -1
View File
@@ -476,12 +476,33 @@ void CommandController::initialize(Settings &, Paths &paths)
this->registerCommand("/usercard", [](const auto &words, auto channel) {
if (words.size() < 2)
{
channel->addMessage(makeSystemMessage("Usage /usercard [user]"));
channel->addMessage(
makeSystemMessage("Usage: /usercard <user> [channel]"));
return "";
}
QString userName = words[1];
stripUserName(userName);
if (words.size() > 2)
{
QString channelName = words[2];
stripChannelName(channelName);
ChannelPtr channelTemp =
getApp()->twitch2->getChannelOrEmpty(channelName);
if (channelTemp->isEmpty())
{
channel->addMessage(makeSystemMessage(
"A usercard can only be displayed for a channel that is "
"currently opened in Chatterino."));
return "";
}
channel = channelTemp;
}
auto *userPopup = new UserInfoPopup(
getSettings()->autoCloseUserPopup,
static_cast<QWidget *>(&(getApp()->windows->getMainWindow())));