summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-10-02 13:23:25 -0400
committerAdam <Adam@anope.org>2013-10-05 00:33:03 -0400
commit257b10ee912698c6378f0d02a851e3c298dc8b78 (patch)
tree74d264f47dcf337bef4a8989a4dab082f6f6429e
parent353ee5cc933b96e92fad807a784ba40505e95a00 (diff)
Hide privileged commands in ns help set and cs help set if configured
-rw-r--r--data/chanserv.example.conf2
-rw-r--r--modules/commands/cs_set.cpp20
-rw-r--r--modules/commands/ns_set.cpp19
3 files changed, 28 insertions, 13 deletions
diff --git a/data/chanserv.example.conf b/data/chanserv.example.conf
index 7ec4487bf..5d827e63d 100644
--- a/data/chanserv.example.conf
+++ b/data/chanserv.example.conf
@@ -1149,7 +1149,7 @@ command { service = "ChanServ"; name = "SET SECUREFOUNDER"; command = "chanserv/
command { service = "ChanServ"; name = "SET SECUREOPS"; command = "chanserv/set/secureops"; }
command { service = "ChanServ"; name = "SET SIGNKICK"; command = "chanserv/set/signkick"; }
command { service = "ChanServ"; name = "SET SUCCESSOR"; command = "chanserv/set/successor"; }
-command { service = "ChanServ"; name = "SET NOEXPIRE"; command = "chanserv/saset/noexpire"; permission = "chanserv/set/noexpire"; }
+command { service = "ChanServ"; name = "SET NOEXPIRE"; command = "chanserv/saset/noexpire"; permission = "chanserv/saset/noexpire"; }
/*
* cs_set_misc
diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp
index 86b874d76..75c9348fe 100644
--- a/modules/commands/cs_set.cpp
+++ b/modules/commands/cs_set.cpp
@@ -35,18 +35,26 @@ class CommandCSSet : public Command
" \n"
"Available options:"));
Anope::string this_name = source.command;
+ bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands");
for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it)
{
const Anope::string &c_name = it->first;
const CommandInfo &info = it->second;
if (c_name.find_ci(this_name + " ") == 0)
{
- ServiceReference<Command> command("Command", info.name);
- if (command)
- {
- source.command = it->first;
- command->OnServHelp(source);
- }
+ ServiceReference<Command> c("Command", info.name);
+
+ if (!c)
+ continue;
+ else if (!hide_privileged_commands)
+ ; // Always show with hide_privileged_commands disabled
+ else if (!c->AllowUnregistered() && !source.GetAccount())
+ continue;
+ else if (!info.permission.empty() && !source.HasCommand(info.permission))
+ continue;
+
+ source.command = it->first;
+ c->OnServHelp(source);
}
}
source.Reply(_("Type \002%s%s HELP %s \037option\037\002 for more information on a\n"
diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp
index deaec6c62..ae7f10376 100644
--- a/modules/commands/ns_set.cpp
+++ b/modules/commands/ns_set.cpp
@@ -33,6 +33,7 @@ class CommandNSSet : public Command
source.Reply(_("Sets various nickname options. \037option\037 can be one of:"));
Anope::string this_name = source.command;
+ bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands");
for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it)
{
const Anope::string &c_name = it->first;
@@ -40,12 +41,18 @@ class CommandNSSet : public Command
if (c_name.find_ci(this_name + " ") == 0)
{
- ServiceReference<Command> command("Command", info.name);
- if (command)
- {
- source.command = c_name;
- command->OnServHelp(source);
- }
+ ServiceReference<Command> c("Command", info.name);
+ if (!c)
+ continue;
+ else if (!hide_privileged_commands)
+ ; // Always show with hide_privileged_commands disabled
+ else if (!c->AllowUnregistered() && !source.GetAccount())
+ continue;
+ else if (!info.permission.empty() && !source.HasCommand(info.permission))
+ continue;
+
+ source.command = c_name;
+ c->OnServHelp(source);
}
}