diff --git a/chatterino.pro b/chatterino.pro index 0660eca3b..7ea3c72ce 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -118,7 +118,6 @@ SOURCES += \ src/providers/bttv/bttvemotes.cpp \ src/providers/ffz/ffzemotes.cpp \ src/providers/emoji/emojis.cpp \ - src/singletons/commandmanager.cpp \ src/singletons/emotemanager.cpp \ src/singletons/fontmanager.cpp \ src/util/completionmodel.cpp \ @@ -249,7 +248,6 @@ HEADERS += \ src/providers/bttv/bttvemotes.hpp \ src/providers/ffz/ffzemotes.hpp \ src/providers/emoji/emojis.hpp \ - src/singletons/commandmanager.hpp \ src/singletons/emotemanager.hpp \ src/singletons/fontmanager.hpp \ src/singletons/helper/chatterinosetting.hpp \ diff --git a/src/controllers/commands/commandcontroller.cpp b/src/controllers/commands/commandcontroller.cpp index 2640f3599..2213258b8 100644 --- a/src/controllers/commands/commandcontroller.cpp +++ b/src/controllers/commands/commandcontroller.cpp @@ -99,9 +99,41 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, QString commandName = words[0]; + // works in a valid twitch channel and /whispers, etc... + if (!dryRun && channel->isTwitchChannel()) { + if (commandName == "/w") { + if (words.length() <= 2) { + return ""; + } + + auto app = getApp(); + + messages::MessageBuilder b; + + b.emplace(app->accounts->twitch.getCurrent()->getUserName(), + messages::MessageElement::Text); + b.emplace("->", messages::MessageElement::Text); + b.emplace(words[1], messages::MessageElement::Text); + + QString rest = ""; + + for (int i = 2; i < words.length(); i++) { + rest += words[i] + " "; + } + + b.emplace(rest, messages::MessageElement::Text); + + app->twitch.server->whispersChannel->addMessage(b.getMessage()); + + app->twitch.server->getWriteConnection()->sendRaw("PRIVMSG #jtv :" + text + "\r\n"); + return ""; + } + } + // check if default command exists auto *twitchChannel = dynamic_cast(channel.get()); + // works only in a valid twitch channel if (!dryRun && twitchChannel != nullptr) { if (commandName == "/debug-args") { QString msg = QApplication::instance()->arguments().join(' '); @@ -152,29 +184,6 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, }); return ""; - } else if (commandName == "/w") { - if (words.length() <= 2) { - return ""; - } - - auto app = getApp(); - - messages::MessageBuilder b; - - b.emplace(app->accounts->twitch.getCurrent()->getUserName(), - messages::MessageElement::Text); - b.emplace("->", messages::MessageElement::Text); - b.emplace(words[1], messages::MessageElement::Text); - - QString rest = ""; - - for (int i = 2; i < words.length(); i++) { - rest += words[i] + " "; - } - - b.emplace(rest, messages::MessageElement::Text); - - app->twitch.server->whispersChannel->addMessage(b.getMessage()); } } diff --git a/src/controllers/commands/commandcontroller.hpp b/src/controllers/commands/commandcontroller.hpp index ececd8c9f..cf2a06ac1 100644 --- a/src/controllers/commands/commandcontroller.hpp +++ b/src/controllers/commands/commandcontroller.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "controllers/commands/command.hpp" #include "util/signalvector2.hpp" diff --git a/src/providers/irc/abstractircserver.cpp b/src/providers/irc/abstractircserver.cpp index 52e97e56f..700f82865 100644 --- a/src/providers/irc/abstractircserver.cpp +++ b/src/providers/irc/abstractircserver.cpp @@ -44,6 +44,11 @@ IrcConnection *AbstractIrcServer::getReadConnection() const return this->readConnection.get(); } +IrcConnection *AbstractIrcServer::getWriteConnection() const +{ + return this->writeConnection.get(); +} + void AbstractIrcServer::connect() { this->disconnect(); diff --git a/src/providers/irc/abstractircserver.hpp b/src/providers/irc/abstractircserver.hpp index 3ac77d88c..4d7bddba1 100644 --- a/src/providers/irc/abstractircserver.hpp +++ b/src/providers/irc/abstractircserver.hpp @@ -20,6 +20,7 @@ public: // connection IrcConnection *getReadConnection() const; + IrcConnection *getWriteConnection() const; void connect(); void disconnect(); diff --git a/src/singletons/commandmanager.cpp b/src/singletons/commandmanager.cpp deleted file mode 100644 index dcb970864..000000000 --- a/src/singletons/commandmanager.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//#include "singletons/commandmanager.hpp" - -//#include "application.hpp" -//#include "debug/log.hpp" - -//#include "channel.hpp" - -// namespace chatterino { -// namespace singletons { - -//} // namespace singletons -//} // namespace chatterino diff --git a/src/singletons/commandmanager.hpp b/src/singletons/commandmanager.hpp deleted file mode 100644 index f0ff1510f..000000000 --- a/src/singletons/commandmanager.hpp +++ /dev/null @@ -1,25 +0,0 @@ -//#pragma once - -//#include -//#include - -//#include -//#include - -//#include -//#include - -// namespace chatterino { -// class Channel; - -// namespace singletons { - -//// -//// this class managed the custom /commands -//// -// class CommandManager -//{ -//}; - -//} // namespace singletons -//} // namespace chatterino