From 6d7fe69cdf9ff1b8fcb149734753c2800894b68e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 9 Mar 2025 18:51:03 +0000 Subject: [PATCH] Add support for oper-only quit messages. This currently only works on InspIRCd but I believe that other servers also support this. --- include/protocol.h | 2 +- modules/nickserv/nickserv.cpp | 4 ++-- modules/protocol/inspircd.cpp | 8 ++++++++ src/bots.cpp | 2 +- src/protocol.cpp | 2 +- src/uplink.cpp | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/protocol.h b/include/protocol.h index b4db070d0..08a41d3da 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -222,7 +222,7 @@ public: virtual void SendContextNotice(BotInfo *bi, User *target, Channel *context, const Anope::string &msg); virtual void SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, const Anope::string &msg); - virtual void SendQuit(User *u, const Anope::string &msg); + virtual void SendQuit(User *u, const Anope::string &msg = "", const Anope::string &opermsg = ""); virtual void SendPing(const Anope::string &servname, const Anope::string &who); virtual void SendPong(const Anope::string &servname, const Anope::string &who); diff --git a/modules/nickserv/nickserv.cpp b/modules/nickserv/nickserv.cpp index c09367914..4221fa114 100644 --- a/modules/nickserv/nickserv.cpp +++ b/modules/nickserv/nickserv.cpp @@ -106,7 +106,7 @@ public: Anope::map::iterator nit = NickServReleases.find(this->nick); if (nit != NickServReleases.end()) { - IRCD->SendQuit(nit->second, ""); + IRCD->SendQuit(nit->second); delete nit->second; } @@ -117,7 +117,7 @@ public: ~NickServRelease() override { - IRCD->SendQuit(this, ""); + IRCD->SendQuit(this); NickServReleases.erase(this->nick); } diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp index e4811f428..fdc78558d 100644 --- a/modules/protocol/inspircd.cpp +++ b/modules/protocol/inspircd.cpp @@ -255,6 +255,14 @@ public: Uplink::Send(user, "SVSCMODE", u->GetUID(), c->name, 'b'); } + void SendQuit(User *u, const Anope::string &buf, const Anope::string &operbuf) + { + if (!operbuf.empty()) + Uplink::Send("METADATA", u->GetUID(), "operquit", operbuf); + + IRCDProto::SendQuit(u, buf, operbuf); + } + void SendPong(const Anope::string &servname, const Anope::string &who) override { Server *serv = servname.empty() ? NULL : Server::Find(servname); diff --git a/src/bots.cpp b/src/bots.cpp index 5aa953672..35a4ccb05 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -66,7 +66,7 @@ BotInfo::~BotInfo() // If we're synchronised with the uplink already, send the bot. if (Me && Me->IsSynced()) { - IRCD->SendQuit(this, ""); + IRCD->SendQuit(this); FOREACH_MOD(OnUserQuit, (this, "")); this->introduced = false; XLine x(this->nick); diff --git a/src/protocol.cpp b/src/protocol.cpp index a45985a0d..7a167582a 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -151,7 +151,7 @@ void IRCDProto::SendTagmsg(const MessageSource &source, const Anope::string &des Uplink::Send(tags, source, "TAGMSG", dest); } -void IRCDProto::SendQuit(User *u, const Anope::string &buf) +void IRCDProto::SendQuit(User *u, const Anope::string &buf, const Anope::string &operbuf) { if (!buf.empty()) Uplink::Send(u, "QUIT", buf); diff --git a/src/uplink.cpp b/src/uplink.cpp index 6e39f163e..981c5e6e5 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -130,7 +130,7 @@ UplinkSocket::~UplinkSocket() if (u->server == Me) { /* Don't use quitmsg here, it may contain information you don't want people to see */ - IRCD->SendQuit(u, "Shutting down"); + IRCD->SendQuit(u, "Shutting down", Anope::QuitReason); BotInfo *bi = BotInfo::Find(u->GetUID()); if (bi != NULL) bi->introduced = false;