Add echo-message support for IRC (#4157)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL 2022-11-18 17:08:15 +01:00 committed by GitHub
parent 49eb5c90cf
commit 8627d6c919
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 1 deletions

View file

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

View file

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

View file

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

View file

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