From 88a487516a99512d0eaec97e016e377269365a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Mon, 24 May 2021 00:24:49 +0200 Subject: [PATCH] Add chat popout command (#2812) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Co-authored-by: Leon Richardt Co-authored-by: lyx0 Co-authored-by: lyx0 <66651385+lyx0@users.noreply.github.com> Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 1 + .../commands/CommandController.cpp | 50 ++++++++++++------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 595c8a867..7bce25261 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Minor: Added moderation buttons to search popup when searching in a split with moderation mode enabled. (#2148, #2803) - Minor: Made "#channel" in `/mentions` tab show in usercards and in the search popup. (#2802) - Minor: Added settings to disable custom FrankerFaceZ VIP/mod badges. (#2693, #2759) +- Minor: Added `/popout` command. Usage: `/popout [channel]`. It opens browser chat for the provided channel. Can also be used without arguments to open current channels browser chat. (#2556, #2812) - Bugfix: Fixed FFZ emote links for global emotes (#2807, #2808) ## 2.3.2 diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index c2970d384..cbf003c50 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -25,8 +25,10 @@ #include "widgets/splits/Split.hpp" #include +#include #include #include +#include namespace { using namespace chatterino; @@ -639,28 +641,42 @@ void CommandController::initialize(Settings &, Paths &paths) this->registerCommand( "/streamlink", [](const QStringList &words, ChannelPtr channel) { - if (words.size() < 2) + QString target(words.size() < 2 ? channel->getName() : words[1]); + + if (words.size() < 2 && + (!channel->isTwitchChannel() || channel->isEmpty())) { - if (!channel->isTwitchChannel() || channel->isEmpty()) - { - channel->addMessage(makeSystemMessage( - "Usage: /streamlink . You can also use the " - "command without arguments in any twitch channel to " - "open it in streamlink.")); - } - else - { - channel->addMessage( - makeSystemMessage(QString("Opening %1 in streamlink...") - .arg(channel->getName()))); - openStreamlinkForChannel(channel->getName()); - } + channel->addMessage(makeSystemMessage( + "Usage: /streamlink [channel]. You can also use the " + "command without arguments in any Twitch channel to open " + "it in streamlink.")); return ""; } channel->addMessage(makeSystemMessage( - QString("Opening %1 in streamlink...").arg(words[1]))); - openStreamlinkForChannel(words[1]); + QString("Opening %1 in streamlink...").arg(target))); + openStreamlinkForChannel(target); + + return ""; + }); + + this->registerCommand( + "/popout", [](const QStringList &words, ChannelPtr channel) { + QString target(words.size() < 2 ? channel->getName() : words[1]); + + if (words.size() < 2 && + (!channel->isTwitchChannel() || channel->isEmpty())) + { + channel->addMessage(makeSystemMessage( + "Usage: /popout [channel]. You can also use the command " + "without arguments in any Twitch channel to open its " + "popout chat.")); + return ""; + } + + QDesktopServices::openUrl( + QUrl(QString("https://www.twitch.tv/popout/%1/chat?popout=") + .arg(target))); return ""; });