From e11677c62b1e320ec98df7c11caadf19482fda83 Mon Sep 17 00:00:00 2001 From: Kasia Date: Mon, 23 May 2022 00:42:52 +0200 Subject: [PATCH] Added /copy command (#3763) Copies the given arguments to clipboard --- CHANGELOG.md | 1 + src/controllers/commands/CommandController.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03756a104..24e0fb4fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Minor: Fixed automod caught message notice appearing twice for mods. (#3717) - Minor: Added `/requests` command. Usage: `/requests [channel]`. Opens the channel points requests queue for the provided channel or the current channel if no input is provided. (#3746) - Minor: Added ability to execute commands on chat messages using the message context menu. (#3738) +- Minor: Added `/copy` command. Usage: `/copy `. Copies provided text to clipboard - can be useful with custom commands. (#3763) - Bugfix: Fixed live notifications for usernames containing uppercase characters. (#3646) - Bugfix: Fixed live notifications not getting updated for closed streams going offline. (#3678) - Bugfix: Fixed certain settings dialogs appearing behind the main window, when `Always on top` was used. (#3679) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index 99525f6f0..843b953a4 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -17,6 +17,7 @@ #include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "singletons/WindowManager.hpp" +#include "util/Clipboard.hpp" #include "util/CombinePath.hpp" #include "util/FormatTime.hpp" #include "util/Helpers.hpp" @@ -825,6 +826,7 @@ void CommandController::initialize(Settings &, Paths &paths) } return ""; }); + this->registerCommand("/setgame", [](const QStringList &words, const ChannelPtr channel) { if (words.size() < 2) @@ -923,6 +925,7 @@ void CommandController::initialize(Settings &, Paths &paths) return ""; }); + this->registerCommand( "/delete", [](const QStringList &words, ChannelPtr channel) -> QString { // This is a wrapper over the standard Twitch /delete command @@ -965,6 +968,7 @@ void CommandController::initialize(Settings &, Paths &paths) getApp()->twitch->sendRawMessage(words.mid(1).join(" ")); return ""; }); + #ifndef NDEBUG this->registerCommand( "/fakemsg", @@ -981,6 +985,19 @@ void CommandController::initialize(Settings &, Paths &paths) return ""; }); #endif + + this->registerCommand( + "/copy", [](const QStringList &words, ChannelPtr channel) -> QString { + if (words.size() < 2) + { + channel->addMessage( + makeSystemMessage("Usage: /copy - copies provided " + "text to clipboard.")); + return ""; + } + crossPlatformCopy(words.mid(1).join(" ")); + return ""; + }); } void CommandController::save()