From fb91c4279bed48860ab9fb127cc657d90ef9b51b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 5 Jul 2021 16:49:52 +0100 Subject: Don't send oper swhois to users with hideoper enabled. --- src/modules/m_swhois.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index de774a171..691e0a3a8 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -93,32 +93,38 @@ class CommandSwhois : public Command }; -class ModuleSWhois : public Module, public Whois::LineEventListener +class ModuleSWhois CXX11_FINAL + : public Module + , public Whois::LineEventListener { +private: CommandSwhois cmd; + UserModeReference hideopermode; public: ModuleSWhois() : Whois::LineEventListener(this) , cmd(this) + , hideopermode(this, "hideoper") { } // :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games. ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { - /* We use this and not OnWhois because this triggers for remote, too */ - if (numeric.GetNumeric() == 312) - { - /* Insert our numeric before 312 */ - std::string* swhois = cmd.swhois.get(whois.GetTarget()); - if (swhois) - { - whois.SendLine(RPL_WHOISSPECIAL, *swhois); - } - } + // We use this and not OnWhois because this triggers for remote users too. + if (numeric.GetNumeric() != RPL_WHOISSERVER) + return MOD_RES_PASSTHRU; + + // Don't send soper swhois if hideoper is set. + if (cmd.operblock.get(whois.GetTarget()) && whois.GetTarget()->IsModeSet(hideopermode)) + return MOD_RES_PASSTHRU; + + // Insert our numeric before RPL_WHOISSERVER. + const std::string* swhois = cmd.swhois.get(whois.GetTarget()); + if (swhois && !swhois->empty()) + whois.SendLine(RPL_WHOISSPECIAL, *swhois); - /* Dont block anything */ return MOD_RES_PASSTHRU; } -- cgit v1.3.1-10-gc9f91