summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-01-13 22:05:30 -0500
committerAdam <Adam@anope.org>2013-01-13 22:07:27 -0500
commitda6543d17b689c31226e1b7ba1ce7de29baee2df (patch)
tree750c38fc64ac41a93c9eb539637ae029239855fd /modules
parent29a018088ecf42c870b78d1539a90776a21276ec (diff)
Allow grouping commands to make help output easier to comprehend
Diffstat (limited to 'modules')
-rw-r--r--modules/commands/cs_info.cpp1
-rw-r--r--modules/commands/help.cpp69
-rw-r--r--modules/pseudoclients/nickserv.cpp21
3 files changed, 83 insertions, 8 deletions
diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp
index a4a0e4151..c007d9341 100644
--- a/modules/commands/cs_info.cpp
+++ b/modules/commands/cs_info.cpp
@@ -31,6 +31,7 @@ class CommandCSInfo : public Command
{
this->SetDesc(_("Lists information about the named registered channel"));
this->SetSyntax(_("\037channel\037"));
+ this->SetFlag(CFLAG_ALLOW_UNREGISTERED);
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp
index 119625000..1bfbdeb77 100644
--- a/modules/commands/help.cpp
+++ b/modules/commands/help.cpp
@@ -15,6 +15,20 @@
class CommandHelp : public Command
{
+ static const unsigned help_wrap_len = 40;
+
+ static CommandGroup *FindGroup(const Anope::string &name)
+ {
+ for (unsigned i = 0; i < Config->CommandGroups.size(); ++i)
+ {
+ CommandGroup &gr = Config->CommandGroups[i];
+ if (gr.name == name)
+ return &gr;
+ }
+
+ return NULL;
+ }
+
public:
CommandHelp(Module *creator) : Command(creator, "generic/help", 0)
{
@@ -29,16 +43,27 @@ class CommandHelp : public Command
if (MOD_RESULT == EVENT_STOP)
return;
+ Anope::string source_command = source.command;
const BotInfo *bi = source.service;
const CommandInfo::map &map = source.c ? Config->Fantasy : bi->commands;
- if (params.empty())
+ if (params.empty() || params[0].equals_ci("ALL"))
{
+ bool all = !params.empty() && params[0].equals_ci("ALL");
+ typedef std::map<CommandGroup *, std::list<Anope::string> > GroupInfo;
+ GroupInfo groups;
+
+ if (all)
+ source.Reply(_("All available commands for \2%s\2:"), source.service->nick.c_str());
+
for (CommandInfo::map::const_iterator it = map.begin(), it_end = map.end(); it != it_end; ++it)
{
const Anope::string &c_name = it->first;
const CommandInfo &info = it->second;
+ if (info.hide)
+ continue;
+
// Smaller command exists
Anope::string cmd;
spacesepstream(c_name).GetToken(cmd, 0);
@@ -55,10 +80,52 @@ class CommandHelp : public Command
else if (!info.permission.empty() && !source.HasCommand(info.permission))
continue;
+ if (!info.group.empty() && !all)
+ {
+ CommandGroup *gr = FindGroup(info.group);
+ if (gr != NULL)
+ {
+ groups[gr].push_back(c_name);
+ continue;
+ }
+ }
+
source.command = c_name;
c->OnServHelp(source);
}
+
+ for (GroupInfo::iterator it = groups.begin(), it_end = groups.end(); it != it_end; ++it)
+ {
+ CommandGroup *gr = it->first;
+
+ source.Reply(" ");
+ source.Reply("%s", gr->description.c_str());
+
+ Anope::string buf;
+ for (std::list<Anope::string>::iterator it2 = it->second.begin(), it2_end = it->second.end(); it2 != it2_end; ++it2)
+ {
+ const Anope::string &c_name = *it2;
+
+ buf += ", " + c_name;
+
+ if (buf.length() > help_wrap_len)
+ {
+ source.Reply(" %s", buf.substr(2).c_str());
+ buf.clear();
+ }
+ }
+ if (buf.length() > 2)
+ {
+ source.Reply(" %s", buf.substr(2).c_str());
+ buf.clear();
+ }
+ }
+ if (!groups.empty())
+ {
+ source.Reply(" ");
+ source.Reply(_("Use the \2%s ALL\2 command to list all command descriptions."), source_command.c_str());
+ }
}
else
{
diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp
index 949b29e68..c2c1e1060 100644
--- a/modules/pseudoclients/nickserv.cpp
+++ b/modules/pseudoclients/nickserv.cpp
@@ -366,12 +366,19 @@ class NickServCore : public Module
{
if (!params.empty() || source.c || source.service->nick != Config->NickServ)
return EVENT_CONTINUE;
- source.Reply(_("\002%s\002 allows you to \"register\" a nickname and\n"
- "prevent others from using it. The following\n"
- "commands allow for registration and maintenance of\n"
- "nicknames; to use them, type \002%s%s \037command\037\002.\n"
- "For more information on a specific command, type\n"
- "\002%s%s %s \037command\037\002.\n "), Config->NickServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), source.command.c_str());
+ if (!Config->NoNicknameOwnership)
+ source.Reply(_("\002%s\002 allows you to register a nickname and\n"
+ "prevent others from using it. The following\n"
+ "commands allow for registration and maintenance of\n"
+ "nicknames; to use them, type \002%s%s \037command\037\002.\n"
+ "For more information on a specific command, type\n"
+ "\002%s%s %s \037command\037\002.\n "), Config->NickServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), source.command.c_str());
+ else
+ source.Reply(_("\002%s\002 allows you to register an account.\n"
+ "The following commands allow for registration and maintenance of\n"
+ "accounts; to use them, type \002%s%s \037command\037\002.\n"
+ "For more information on a specific command, type\n"
+ "\002%s%s %s \037command\037\002.\n "), Config->NickServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), source.command.c_str());
return EVENT_CONTINUE;
}
@@ -386,7 +393,7 @@ class NickServCore : public Module
"any nickname."));
if (Config->NSExpire >= 86400)
source.Reply(_(" \n"
- "Nicknames that are not used anymore are subject to \n"
+ "Accounts that are not used anymore are subject to \n"
"the automatic expiration, i.e. they will be deleted\n"
"after %d days if not used."), Config->NSExpire / 86400);
source.Reply(_(" \n"