fixed sending whispers from /whispers

This commit is contained in:
fourtf 2018-06-05 18:51:14 +02:00
parent b410db844d
commit 51bde1098e
7 changed files with 39 additions and 62 deletions

View file

@ -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 \

View file

@ -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<messages::TextElement>(app->accounts->twitch.getCurrent()->getUserName(),
messages::MessageElement::Text);
b.emplace<messages::TextElement>("->", messages::MessageElement::Text);
b.emplace<messages::TextElement>(words[1], messages::MessageElement::Text);
QString rest = "";
for (int i = 2; i < words.length(); i++) {
rest += words[i] + " ";
}
b.emplace<messages::TextElement>(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<TwitchChannel *>(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<messages::TextElement>(app->accounts->twitch.getCurrent()->getUserName(),
messages::MessageElement::Text);
b.emplace<messages::TextElement>("->", messages::MessageElement::Text);
b.emplace<messages::TextElement>(words[1], messages::MessageElement::Text);
QString rest = "";
for (int i = 2; i < words.length(); i++) {
rest += words[i] + " ";
}
b.emplace<messages::TextElement>(rest, messages::MessageElement::Text);
app->twitch.server->whispersChannel->addMessage(b.getMessage());
}
}

View file

@ -2,6 +2,7 @@
#include <QMap>
#include <memory>
#include <mutex>
#include "controllers/commands/command.hpp"
#include "util/signalvector2.hpp"

View file

@ -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();

View file

@ -20,6 +20,7 @@ public:
// connection
IrcConnection *getReadConnection() const;
IrcConnection *getWriteConnection() const;
void connect();
void disconnect();

View file

@ -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

View file

@ -1,25 +0,0 @@
//#pragma once
//#include <QMap>
//#include <QString>
//#include <memory>
//#include <mutex>
//#include <util/signalvector2.hpp>
//#include <util/signalvectormodel.hpp>
// namespace chatterino {
// class Channel;
// namespace singletons {
////
//// this class managed the custom /commands
////
// class CommandManager
//{
//};
//} // namespace singletons
//} // namespace chatterino