diff options
-rw-r--r-- | data/botserv.example.conf | 2 | ||||
-rw-r--r-- | modules/commands/bs_set.cpp | 9 | ||||
-rw-r--r-- | modules/commands/cs_set.cpp | 10 | ||||
-rw-r--r-- | modules/commands/ns_set.cpp | 10 |
4 files changed, 20 insertions, 11 deletions
diff --git a/data/botserv.example.conf b/data/botserv.example.conf index 6cb44afc3..1b849ac60 100644 --- a/data/botserv.example.conf +++ b/data/botserv.example.conf @@ -202,7 +202,7 @@ command { service = "BotServ"; name = "BADWORDS"; command = "botserv/badwords"; * Used for administrating BotServ bots. */ module { name = "bs_bot" } -command { service = "BotServ"; name = "BOT"; command = "botserv/bot"; } +command { service = "BotServ"; name = "BOT"; command = "botserv/bot"; permission = "botserv/bot"; } /* * bs_botlist diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp index 819ac42b3..cbe6adbe0 100644 --- a/modules/commands/bs_set.cpp +++ b/modules/commands/bs_set.cpp @@ -32,6 +32,8 @@ class CommandBSSet : public Command source.Reply(_("Configures bot options.\n" " \n" "Available options:")); + bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"), + hide_registered_commands = Config->GetBlock("options")->Get<bool>("hideregisteredcommands"); Anope::string this_name = source.command; for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it) { @@ -42,6 +44,13 @@ class CommandBSSet : public Command ServiceReference<Command> command("Command", info.name); if (command) { + // XXX dup + if (hide_registered_commands && !command->AllowUnregistered() && !source.GetAccount()) + continue; + + if (hide_privileged_commands && !info.permission.empty() && !source.HasCommand(info.permission)) + continue; + source.command = it->first; command->OnServHelp(source); } diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 1109c888e..77e1d1fd5 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -35,7 +35,8 @@ class CommandCSSet : public Command " \n" "Available options:")); Anope::string this_name = source.command; - bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"); + bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"), + hide_registered_commands = Config->GetBlock("options")->Get<bool>("hideregisteredcommands"); 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; @@ -44,13 +45,12 @@ class CommandCSSet : public Command { ServiceReference<Command> c("Command", info.name); + // XXX dup if (!c) continue; - else if (!hide_privileged_commands) - ; // Always show with hide_privileged_commands disabled - else if (!c->AllowUnregistered() && !source.GetAccount()) + else if (hide_registered_commands && !c->AllowUnregistered() && !source.GetAccount()) continue; - else if (!info.permission.empty() && !source.HasCommand(info.permission)) + else if (hide_privileged_commands && !info.permission.empty() && !source.HasCommand(info.permission)) continue; source.command = it->first; diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index f4ecd044b..03ebae85c 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -33,7 +33,8 @@ 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"); + bool hide_privileged_commands = Config->GetBlock("options")->Get<bool>("hideprivilegedcommands"), + hide_registered_commands = Config->GetBlock("options")->Get<bool>("hideregisteredcommands"); 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; @@ -42,13 +43,12 @@ class CommandNSSet : public Command if (c_name.find_ci(this_name + " ") == 0) { ServiceReference<Command> c("Command", info.name); + // XXX dup if (!c) continue; - else if (!hide_privileged_commands) - ; // Always show with hide_privileged_commands disabled - else if (!c->AllowUnregistered() && !source.GetAccount()) + else if (hide_registered_commands && !c->AllowUnregistered() && !source.GetAccount()) continue; - else if (!info.permission.empty() && !source.HasCommand(info.permission)) + else if (hide_privileged_commands && !info.permission.empty() && !source.HasCommand(info.permission)) continue; source.command = c_name; |