From 13c9aabf2992e3f6bb3aca5838fcb92a20001d14 Mon Sep 17 00:00:00 2001 From: fourtf Date: Mon, 16 Sep 2019 18:01:32 +0200 Subject: [PATCH] show all irc messages for debugging --- src/providers/irc/AbstractIrcServer.cpp | 20 ++++++++++++++++++-- src/providers/irc/IrcConnection2.cpp | 2 +- src/providers/irc/IrcServer.cpp | 15 ++++++++++++++- src/providers/twitch/TwitchIrcServer.cpp | 7 ++++++- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/providers/irc/AbstractIrcServer.cpp b/src/providers/irc/AbstractIrcServer.cpp index 30952a6d3..ce2c4e298 100644 --- a/src/providers/irc/AbstractIrcServer.cpp +++ b/src/providers/irc/AbstractIrcServer.cpp @@ -328,7 +328,10 @@ std::shared_ptr AbstractIrcServer::getCustomChannel( QString AbstractIrcServer::cleanChannelName(const QString &dirtyChannelName) { - return dirtyChannelName; + if (dirtyChannelName.startsWith('#')) + return dirtyChannelName.mid(1); + else + return dirtyChannelName; } void AbstractIrcServer::addFakeMessage(const QString &data) @@ -356,7 +359,20 @@ void AbstractIrcServer::privateMessageReceived( void AbstractIrcServer::readConnectionMessageReceived( Communi::IrcMessage *message) { - (void)message; + /* XXX: only print this message once + if (message->type() == Communi::IrcMessage::Join) + { + auto x = static_cast(message); + + if (auto it = this->channels.find(this->cleanChannelName(x->channel())); + it != this->channels.end()) + { + if (auto shared = it->lock()) + shared->addMessage( + MessageBuilder(systemMessage, "joined").release()); + } + } + */ } void AbstractIrcServer::forEachChannel(std::function func) diff --git a/src/providers/irc/IrcConnection2.cpp b/src/providers/irc/IrcConnection2.cpp index c6065f8bc..242aa7bf3 100644 --- a/src/providers/irc/IrcConnection2.cpp +++ b/src/providers/irc/IrcConnection2.cpp @@ -13,7 +13,7 @@ IrcConnection::IrcConnection(QObject *parent) { if (!this->recentlyReceivedMessage_.load()) { - this->sendRaw("PING"); + this->sendRaw("PING chatterino/ping"); this->reconnectTimer_.start(); } this->recentlyReceivedMessage_ = false; diff --git a/src/providers/irc/IrcServer.cpp b/src/providers/irc/IrcServer.cpp index 1ef1ffc99..a9f7dd5da 100644 --- a/src/providers/irc/IrcServer.cpp +++ b/src/providers/irc/IrcServer.cpp @@ -131,7 +131,20 @@ void IrcServer::privateMessageReceived(Communi::IrcPrivateMessage *message) void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message) { - qDebug() << QString(message->toData()); + AbstractIrcServer::readConnectionMessageReceived(message); + + MessageBuilder builder; + + builder.emplace(); + builder.emplace(message->toData(), MessageElementFlag::Text); + + auto msg = builder.release(); + + for (auto &&weak : this->channels) + { + if (auto shared = weak.lock()) + shared->addMessage(msg); + } } } // namespace chatterino diff --git a/src/providers/twitch/TwitchIrcServer.cpp b/src/providers/twitch/TwitchIrcServer.cpp index 271536e9c..f52f66029 100644 --- a/src/providers/twitch/TwitchIrcServer.cpp +++ b/src/providers/twitch/TwitchIrcServer.cpp @@ -131,6 +131,8 @@ void TwitchIrcServer::privateMessageReceived( void TwitchIrcServer::readConnectionMessageReceived( Communi::IrcMessage *message) { + AbstractIrcServer::readConnectionMessageReceived(message); + if (message->type() == Communi::IrcMessage::Type::Private) { // We already have a handler for private messages @@ -287,7 +289,10 @@ std::shared_ptr TwitchIrcServer::getChannelOrEmptyByID( QString TwitchIrcServer::cleanChannelName(const QString &dirtyChannelName) { - return dirtyChannelName.toLower(); + if (dirtyChannelName.startsWith('#')) + return dirtyChannelName.mid(1).toLower(); + else + return dirtyChannelName.toLower(); } bool TwitchIrcServer::hasSeparateWriteConnection() const