aboutsummaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-11-29 04:52:42 +0000
committerGravatar Sadie Powell2022-11-29 04:52:42 +0000
commitf9ef385b890756e31871426502e52ebc66622894 (patch)
treee843804c28651b07863f76a4ad7c8f082dc0bc6d /src/users.cpp
parentRefactor 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/users.cpp')
-rw-r--r--src/users.cpp36
1 files changed, 36 insertions, 0 deletions
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<ConfigTag>& tag, bool merge)
MergeTag(tag);
}
+std::string OperType::GetCommands() const
+{
+ std::vector<std::string> 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);