diff --git a/CHANGELOG.md b/CHANGELOG.md index 22e37883..d85623f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,7 @@ - Minor: Add settings tooltips. (#3437) - Minor: Add setting to limit message input length. (#3418) - Minor: Make built-in commands work in IRC channels. (#4160) +- Minor: Add support for `echo-message` capabilities for IRC. (#4157) - Minor: Improved look of tabs when using a layout other than top. (#3925, #4152) - Bugfix: Fixed channels with two leading `#`s not being usable on IRC (#4154) - Bugfix: Fixed `Add new account` dialog causing main chatterino window to be non movable. (#4121) diff --git a/src/providers/irc/IrcChannel2.cpp b/src/providers/irc/IrcChannel2.cpp index 19140b4e..84f9ce22 100644 --- a/src/providers/irc/IrcChannel2.cpp +++ b/src/providers/irc/IrcChannel2.cpp @@ -38,7 +38,10 @@ void IrcChannel::sendMessage(const QString &message) if (this->server() != nullptr) { this->server()->sendMessage(this->getName(), message); - + if (this->server()->hasEcho()) + { + return; + } MessageBuilder builder; builder diff --git a/src/providers/irc/IrcServer.cpp b/src/providers/irc/IrcServer.cpp index e148e5b0..964b22d9 100644 --- a/src/providers/irc/IrcServer.cpp +++ b/src/providers/irc/IrcServer.cpp @@ -111,6 +111,15 @@ void IrcServer::initializeConnectionSignals(IrcConnection *connection, } } }); + QObject::connect(connection, + &Communi::IrcConnection::capabilityMessageReceived, this, + [this](Communi::IrcCapabilityMessage *message) { + const QStringList caps = message->capabilities(); + if (caps.contains("echo-message")) + { + this->hasEcho_ = true; + } + }); } void IrcServer::initializeConnection(IrcConnection *connection, @@ -127,6 +136,7 @@ void IrcServer::initializeConnection(IrcConnection *connection, : this->data_->nick); connection->setRealName(this->data_->real.isEmpty() ? this->data_->user : this->data_->nick); + connection->network()->setRequestedCapabilities({"echo-message"}); if (getSettings()->enableExperimentalIrc) { @@ -289,4 +299,9 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message) } } +bool IrcServer::hasEcho() const +{ + return this->hasEcho_; +} + } // namespace chatterino diff --git a/src/providers/irc/IrcServer.hpp b/src/providers/irc/IrcServer.hpp index 9ebc8b90..417879f9 100644 --- a/src/providers/irc/IrcServer.hpp +++ b/src/providers/irc/IrcServer.hpp @@ -20,6 +20,8 @@ public: const QString &nick(); const QString &userFriendlyIdentifier(); + bool hasEcho() const; + // AbstractIrcServer interface protected: void initializeConnectionSignals(IrcConnection *connection, @@ -36,6 +38,8 @@ protected: private: // pointer so we don't have to circle include Irc2.hpp IrcServerData *data_; + + bool hasEcho_{false}; }; } // namespace chatterino