From f9ef385b890756e31871426502e52ebc66622894 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 29 Nov 2022 04:52:42 +0000 Subject: Move the oper statistics to core_oper and rewrite. The numerics we used previously were not being used according to the RFC and every implementation has their own behaviour here which makes it hard for clients to do anything reasonable. Instead of this using the generic stats numeric makes a lot more sense. --- src/modules/m_hideoper.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/modules/m_hideoper.cpp') diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 27f717aac..d0e45313b 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -147,20 +147,27 @@ public: if (stats.GetSymbol() != 'P') return MOD_RES_PASSTHRU; - unsigned int count = 0; + size_t opers = 0; for (const auto& oper : ServerInstance->Users.all_opers) { - if (!oper->server->IsService() && (stats.GetSource()->IsOper() || !oper->IsModeSet(hm))) + if (oper->server->IsService()) + continue; + + opers++; + auto loper = IS_LOCAL(oper); + if (loper) + { + const std::string idleperiod = InspIRCd::DurationString(ServerInstance->Time() - loper->idle_lastmsg); + const std::string idletime = InspIRCd::TimeString(ServerInstance->Time()); + stats.AddGenericRow(InspIRCd::Format("\x02%s\x02 (%s): idle for %s [since %s]", oper->nick.c_str(), + oper->MakeHost().c_str(), idleperiod.c_str(), idletime.c_str())); + } + else { - LocalUser* lu = IS_LOCAL(oper); - const std::string idle = lu ? InspIRCd::DurationString(ServerInstance->Time() - lu->idle_lastmsg) : "unavailable"; - stats.AddRow(249, InspIRCd::Format("%s (%s@%s) Idle: %s", oper->nick.c_str(), - oper->ident.c_str(), oper->GetDisplayedHost().c_str(), idle.c_str())); - count++; + stats.AddGenericRow(InspIRCd::Format("\x02%s\x02 (%s)", oper->nick.c_str(), oper->MakeHost().c_str())); } } - stats.AddRow(249, ConvToStr(count)+" OPER(s)"); - + stats.AddGenericRow(InspIRCd::Format("%zu server operator%s total", opers, opers ? "s" : "")); return MOD_RES_DENY; } }; -- cgit v1.3.1-10-gc9f91