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/users.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index 5f99b8d90..e901f6653 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1288,6 +1288,42 @@ void OperType::Configure(const std::shared_ptr& tag, bool merge) MergeTag(tag); } +std::string OperType::GetCommands() const +{ + std::vector ret; + for (const auto& [_, cmd] : ServerInstance->Parser.GetCommands()) + { + if (cmd->access_needed == CmdAccess::OPERATOR && CanUseCommand(cmd->name)) + ret.push_back(cmd->name); + } + std::sort(ret.begin(), ret.end()); + return stdalgo::string::join(ret); +} + +std::string OperType::GetModes(ModeType mt) const +{ + std::string ret; + for (const auto& [_, mh] : ServerInstance->Modes.GetModes(mt)) + { + if (mh->NeedsOper() && CanUseMode(mh)) + ret.push_back(mh->GetModeChar()); + } + std::sort(ret.begin(), ret.end()); + return ret; +} + +std::string OperType::GetSnomasks() const +{ + std::string ret; + for (unsigned char sno = 'A'; sno <= 'z'; ++sno) + { + if (CanUseSnomask(sno)) + ret.push_back(sno); + } + std::sort(ret.begin(), ret.end()); + return ret; +} + bool OperType::CanUseCommand(const std::string& cmd) const { return commands.Contains(cmd); -- cgit v1.3.1-10-gc9f91