Move ChatSettings commands to their own file (#4116)

* Move ChatSettings commands to their own file

* reformat error message strings

* move ChatCommands together in CommandController.cpp

* Allow CommandContext to be provided for builtin functions

using variants MEGADANK

* add missing include

* rename to ComandFunctionVariants

also include some move magic & const reffing
This commit is contained in:
pajlada
2022-11-06 13:07:54 +01:00
committed by GitHub
parent ac7baf4073
commit c6a162c7ff
6 changed files with 526 additions and 469 deletions
+10 -2
View File
@@ -4,6 +4,7 @@
#include "common/SignalVector.hpp"
#include "common/Singleton.hpp"
#include "controllers/commands/Command.hpp"
#include "controllers/commands/CommandContext.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include <QMap>
@@ -12,6 +13,7 @@
#include <memory>
#include <mutex>
#include <unordered_map>
#include <variant>
namespace chatterino {
@@ -46,10 +48,16 @@ private:
using CommandFunction =
std::function<QString(QStringList /*words*/, ChannelPtr /*channel*/)>;
void registerCommand(QString commandName, CommandFunction commandFunction);
using CommandFunctionWithContext = std::function<QString(CommandContext)>;
using CommandFunctionVariants =
std::variant<CommandFunction, CommandFunctionWithContext>;
void registerCommand(const QString &commandName,
CommandFunctionVariants commandFunction);
// Chatterino commands
QMap<QString, CommandFunction> commands_;
std::unordered_map<QString, CommandFunctionVariants> commands_;
// User-created commands
QMap<QString, Command> userCommands_;