diff options
| author | 2022-11-29 04:52:42 +0000 | |
|---|---|---|
| committer | 2022-11-29 04:52:42 +0000 | |
| commit | f9ef385b890756e31871426502e52ebc66622894 (patch) | |
| tree | e843804c28651b07863f76a4ad7c8f082dc0bc6d /src/modules/m_hideoper.cpp | |
| parent | Refactor the internals of the oper system. (diff) | |
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.
Diffstat (limited to 'src/modules/m_hideoper.cpp')
| -rw-r--r-- | src/modules/m_hideoper.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
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; } }; |
