diff options
author | Adam <Adam@anope.org> | 2013-01-13 22:05:30 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-01-13 22:07:27 -0500 |
commit | da6543d17b689c31226e1b7ba1ce7de29baee2df (patch) | |
tree | 750c38fc64ac41a93c9eb539637ae029239855fd | |
parent | 29a018088ecf42c870b78d1539a90776a21276ec (diff) |
Allow grouping commands to make help output easier to comprehend
-rw-r--r-- | data/chanserv.example.conf | 162 | ||||
-rw-r--r-- | data/nickserv.example.conf | 47 | ||||
-rw-r--r-- | include/bots.h | 3 | ||||
-rw-r--r-- | include/commands.h | 11 | ||||
-rw-r--r-- | include/config.h | 2 | ||||
-rw-r--r-- | modules/commands/cs_info.cpp | 1 | ||||
-rw-r--r-- | modules/commands/help.cpp | 69 | ||||
-rw-r--r-- | modules/pseudoclients/nickserv.cpp | 21 | ||||
-rw-r--r-- | src/bots.cpp | 3 | ||||
-rw-r--r-- | src/config.cpp | 46 |
10 files changed, 265 insertions, 100 deletions
diff --git a/data/chanserv.example.conf b/data/chanserv.example.conf index fa58d4fc6..276697bb0 100644 --- a/data/chanserv.example.conf +++ b/data/chanserv.example.conf @@ -844,6 +844,35 @@ privilege * Sane defaults are provided below that do not need to be edited unless you wish to change the default behavior. */ +/* Command group configuration for ChanServ. + * + * Commands may optionally be placed into groups to make ChanServ's HELP output easier to understand. + * Remove the following groups to use the old behavior of simply listing all ChanServ commands from HELP. + */ +command_group +{ + name = "chanserv/access" + description = "Used to manage the list of privileged users" +} + +command_group +{ + name = "chanserv/status" + description = "Used to modify the channel status of you or other users" +} + +command_group +{ + name = "chanserv/management" + description = "Used to manage channels" +} + +command_group +{ + name = "chanserv/admin"; + description = "Servies Operator commands" +} + /* Give it a help command */ command { service = "ChanServ"; name = "HELP"; command = "generic/help"; } @@ -856,8 +885,8 @@ command { service = "ChanServ"; name = "HELP"; command = "generic/help"; } * Used for giving users access in channels. */ module { name = "cs_access" } -command { service = "ChanServ"; name = "ACCESS"; command = "chanserv/access"; } -command { service = "ChanServ"; name = "LEVELS"; command = "chanserv/levels"; } +command { service = "ChanServ"; name = "ACCESS"; command = "chanserv/access"; group = "chanserv/access" } +command { service = "ChanServ"; name = "LEVELS"; command = "chanserv/levels"; group = "chanserv/access" } /* * cs_akick @@ -867,7 +896,7 @@ command { service = "ChanServ"; name = "LEVELS"; command = "chanserv/levels"; } * Used for preventing users from joining channels. */ module { name = "cs_akick" } -command { service = "ChanServ"; name = "AKICK"; command = "chanserv/akick"; } +command { service = "ChanServ"; name = "AKICK"; command = "chanserv/akick"; group = "chanserv/management" } /* * cs_ban @@ -887,7 +916,7 @@ command { service = "ChanServ"; name = "BAN"; command = "chanserv/ban"; } * Used for copying channel settings from one channel to another. */ module { name = "cs_clone" } -command { service = "ChanServ"; name = "CLONE"; command = "chanserv/clone"; } +command { service = "ChanServ"; name = "CLONE"; command = "chanserv/clone"; group = "chanserv/management" } /* * cs_drop @@ -907,7 +936,7 @@ command { service = "ChanServ"; name = "DROP"; command = "chanserv/drop"; } * Used to enforce various channel settings such as secureops and restricted. */ module { name = "cs_enforce" } -command { service = "ChanServ"; name = "ENFORCE"; command = "chanserv/enforce"; } +command { service = "ChanServ"; name = "ENFORCE"; command = "chanserv/enforce"; group = "chanserv/management" } /* * cs_entrymsg @@ -917,7 +946,7 @@ command { service = "ChanServ"; name = "ENFORCE"; command = "chanserv/enforce"; * Used to configure entry messages sent to users when they join a channel. */ module { name = "cs_entrymsg" } -command { service = "ChanServ"; name = "ENTRYMSG"; command = "chanserv/entrymsg"; } +command { service = "ChanServ"; name = "ENTRYMSG"; command = "chanserv/entrymsg"; group = "chanserv/management" } cs_entrymsg { /* The maximum number of entrymsgs allowed per channel. If not set, defaults to 5. */ @@ -933,7 +962,7 @@ cs_entrymsg * Used for giving users access in channels. */ module { name = "cs_flags" } -command { service = "ChanServ"; name = "FLAGS"; command = "chanserv/flags"; } +command { service = "ChanServ"; name = "FLAGS"; command = "chanserv/flags"; group = "chanserv/access" } /* * cs_getkey @@ -983,7 +1012,7 @@ command { service = "ChanServ"; name = "KICK"; command = "chanserv/kick"; } * Used for retrieving and searching the registered channel list. */ module { name = "cs_list" } -command { service = "ChanServ"; name = "LIST"; command = "chanserv/list"; permission = "chanserv/list"; } +command { service = "ChanServ"; name = "LIST"; command = "chanserv/list"; permission = "chanserv/list"; group = "chanserv/admin" } /* * cs_log @@ -993,7 +1022,7 @@ command { service = "ChanServ"; name = "LIST"; command = "chanserv/list"; permis * Use for configuring what actions on channels are logged and where. */ module { name = "cs_log" } -command { service = "ChanServ"; name = "LOG"; command = "chanserv/log"; } +command { service = "ChanServ"; name = "LOG"; command = "chanserv/log"; group = "chanserv/management" } /* * cs_mode @@ -1003,7 +1032,7 @@ command { service = "ChanServ"; name = "LOG"; command = "chanserv/log"; } * Used for changing mode locks and changing modes. */ module { name = "cs_mode" } -command { service = "ChanServ"; name = "MODE"; command = "chanserv/mode"; } +command { service = "ChanServ"; name = "MODE"; command = "chanserv/mode"; group = "chanserv/management" } /* * cs_register @@ -1024,7 +1053,6 @@ command { service = "ChanServ"; name = "REGISTER"; command = "chanserv/register" * Also allows administrators to view stats about seen data and purge the database. */ module { name = "cs_seen" } -command { service = "ChanServ"; name = "SEEN"; command = "chanserv/seen"; } command { service = "OperServ"; name = "SEEN"; command = "operserv/seen"; } cs_seen { @@ -1060,55 +1088,55 @@ cs_seen */ module { name = "cs_set" } -command { service = "ChanServ"; name = "SET"; command = "chanserv/set"; } -command { service = "ChanServ"; name = "SASET"; command = "chanserv/saset"; permission = "chanserv/saset/"; } +command { service = "ChanServ"; name = "SET"; command = "chanserv/set"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET"; command = "chanserv/saset"; permission = "chanserv/saset/"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET AUTOOP"; command = "chanserv/set/autoop"; } -command { service = "ChanServ"; name = "SASET AUTOOP"; command = "chanserv/set/autoop"; permission = "chanserv/saset/autoop"; } +command { service = "ChanServ"; name = "SET AUTOOP"; command = "chanserv/set/autoop"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET AUTOOP"; command = "chanserv/set/autoop"; permission = "chanserv/saset/autoop"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET BANTYPE"; command = "chanserv/set/bantype"; } -command { service = "ChanServ"; name = "SASET BANTYPE"; command = "chanserv/set/bantype"; permission = "chanserv/saset/bantype"; } +command { service = "ChanServ"; name = "SET BANTYPE"; command = "chanserv/set/bantype"; group = "chanserv/management"} +command { service = "ChanServ"; name = "SASET BANTYPE"; command = "chanserv/set/bantype"; permission = "chanserv/saset/bantype"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET DESCRIPTION"; command = "chanserv/set/description"; } -command { service = "ChanServ"; name = "SET DESC"; command = "chanserv/set/description"; } +command { service = "ChanServ"; name = "SET DESCRIPTION"; command = "chanserv/set/description"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SET DESC"; command = "chanserv/set/description"; group = "chanserv/management" } -command { service = "ChanServ"; name = "SASET DESCRIPTION"; command = "chanserv/set/description"; permission = "chanserv/saset/description"; } -command { service = "ChanServ"; name = "SASET DESC"; command = "chanserv/set/description"; permission = "chanserv/saset/description"; } +command { service = "ChanServ"; name = "SASET DESCRIPTION"; command = "chanserv/set/description"; permission = "chanserv/saset/description"; group = "chanserv/admin" } +command { service = "ChanServ"; name = "SASET DESC"; command = "chanserv/set/description"; permission = "chanserv/saset/description"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET FOUNDER"; command = "chanserv/set/founder"; } -command { service = "ChanServ"; name = "SASET FOUNDER"; command = "chanserv/set/founder"; permission = "chanserv/saset/founder"; } +command { service = "ChanServ"; name = "SET FOUNDER"; command = "chanserv/set/founder"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET FOUNDER"; command = "chanserv/set/founder"; permission = "chanserv/saset/founder"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET KEEPTOPIC"; command = "chanserv/set/keeptopic"; } -command { service = "ChanServ"; name = "SASET KEEPTOPIC"; command = "chanserv/set/keeptopic"; permission = "chanserv/saset/keeptopic"; } +command { service = "ChanServ"; name = "SET KEEPTOPIC"; command = "chanserv/set/keeptopic"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET KEEPTOPIC"; command = "chanserv/set/keeptopic"; permission = "chanserv/saset/keeptopic"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET PEACE"; command = "chanserv/set/peace"; } -command { service = "ChanServ"; name = "SASET PEACE"; command = "chanserv/set/peace"; permission = "chanserv/saset/peace"; } +command { service = "ChanServ"; name = "SET PEACE"; command = "chanserv/set/peace"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET PEACE"; command = "chanserv/set/peace"; permission = "chanserv/saset/peace"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET PERSIST"; command = "chanserv/set/persist"; } -command { service = "ChanServ"; name = "SASET PERSIST"; command = "chanserv/set/persist"; permission = "chanserv/saset/persist"; } +command { service = "ChanServ"; name = "SET PERSIST"; command = "chanserv/set/persist"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET PERSIST"; command = "chanserv/set/persist"; permission = "chanserv/saset/persist"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET PRIVATE"; command = "chanserv/set/private"; } -command { service = "ChanServ"; name = "SASET PRIVATE"; command = "chanserv/set/private"; permission = "chanserv/saset/private"; } +command { service = "ChanServ"; name = "SET PRIVATE"; command = "chanserv/set/private"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET PRIVATE"; command = "chanserv/set/private"; permission = "chanserv/saset/private"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET RESTRICTED"; command = "chanserv/set/restricted"; } -command { service = "ChanServ"; name = "SASET RESTRICTED"; command = "chanserv/set/restricted"; permission = "chanserv/saset/restricted"; } +command { service = "ChanServ"; name = "SET RESTRICTED"; command = "chanserv/set/restricted"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET RESTRICTED"; command = "chanserv/set/restricted"; permission = "chanserv/saset/restricted"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET SECURE"; command = "chanserv/set/secure"; } -command { service = "ChanServ"; name = "SASET SECURE"; command = "chanserv/set/secure"; permission = "chanserv/saset/secure"; } +command { service = "ChanServ"; name = "SET SECURE"; command = "chanserv/set/secure"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET SECURE"; command = "chanserv/set/secure"; permission = "chanserv/saset/secure"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET SECUREFOUNDER"; command = "chanserv/set/securefounder"; } -command { service = "ChanServ"; name = "SASET SECUREFOUNDER"; command = "chanserv/set/securefounder"; permission = "chanserv/saset/securefounder"; } +command { service = "ChanServ"; name = "SET SECUREFOUNDER"; command = "chanserv/set/securefounder"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET SECUREFOUNDER"; command = "chanserv/set/securefounder"; permission = "chanserv/saset/securefounder"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET SECUREOPS"; command = "chanserv/set/secureops"; } -command { service = "ChanServ"; name = "SASET SECUREOPS"; command = "chanserv/set/secureops"; permission = "chanserv/saset/secureops"; } +command { service = "ChanServ"; name = "SET SECUREOPS"; command = "chanserv/set/secureops"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET SECUREOPS"; command = "chanserv/set/secureops"; permission = "chanserv/saset/secureops"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET SIGNKICK"; command = "chanserv/set/signkick"; } -command { service = "ChanServ"; name = "SASET SIGNKICK"; command = "chanserv/set/signkick"; permission = "chanserv/saset/signkick"; } +command { service = "ChanServ"; name = "SET SIGNKICK"; command = "chanserv/set/signkick"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET SIGNKICK"; command = "chanserv/set/signkick"; permission = "chanserv/saset/signkick"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SET SUCCESSOR"; command = "chanserv/set/successor"; } -command { service = "ChanServ"; name = "SASET SUCCESSOR"; command = "chanserv/set/successor"; permission = "chanserv/saset/successor"; } +command { service = "ChanServ"; name = "SET SUCCESSOR"; command = "chanserv/set/successor"; group = "chanserv/management" } +command { service = "ChanServ"; name = "SASET SUCCESSOR"; command = "chanserv/set/successor"; permission = "chanserv/saset/successor"; group = "chanserv/admin" } -command { service = "ChanServ"; name = "SASET NOEXPIRE"; command = "chanserv/saset/noexpire"; permission = "chanserv/saset/noexpire"; } +command { service = "ChanServ"; name = "SASET NOEXPIRE"; command = "chanserv/saset/noexpire"; permission = "chanserv/saset/noexpire"; group = "chanserv/admin" } /* * cs_set_misc @@ -1119,8 +1147,8 @@ command { service = "ChanServ"; name = "SASET NOEXPIRE"; command = "chanserv/sas * A field named misc_description may be given for use with help output. */ module { name = "cs_set_misc" } -command { service = "ChanServ"; name = "SET URL"; command = "chanserv/set/misc"; misc_description = _("Associate a URL with the channel") } -command { service = "ChanServ"; name = "SET EMAIL"; command = "chanserv/set/misc"; misc_description = _("Associate an E-mail address with the channel") } +command { service = "ChanServ"; name = "SET URL"; command = "chanserv/set/misc"; group = "chanserv/management"; misc_description = _("Associate a URL with the channel") } +command { service = "ChanServ"; name = "SET EMAIL"; command = "chanserv/set/misc"; group = "chanserv/management"; misc_description = _("Associate an E-mail address with the channel") } /* * cs_status @@ -1141,8 +1169,8 @@ command { service = "ChanServ"; name = "STATUS"; command = "chanserv/status"; } * Used for suspending and unsuspending channels. Suspended channels can not be used but their settings are stored. */ module { name = "cs_suspend" } -command { service = "ChanServ"; name = "SUSPEND"; command = "chanserv/suspend"; permission = "chanserv/suspend"; } -command { service = "ChanServ"; name = "UNSUSPEND"; command = "chanserv/unsuspend"; permission = "chanserv/suspend"; } +command { service = "ChanServ"; name = "SUSPEND"; command = "chanserv/suspend"; permission = "chanserv/suspend"; group = "chanserv/admin" } +command { service = "ChanServ"; name = "UNSUSPEND"; command = "chanserv/unsuspend"; permission = "chanserv/suspend"; group = "chanserv/admin" } /* * cs_sync @@ -1152,7 +1180,7 @@ command { service = "ChanServ"; name = "UNSUSPEND"; command = "chanserv/unsuspen * Used to sync users channel status modes with what access they have. */ module { name = "cs_sync" } -command { service = "ChanServ"; name = "SYNC"; command = "chanserv/sync"; } +command { service = "ChanServ"; name = "SYNC"; command = "chanserv/sync"; group = "chanserv/management" } /* * cs_topic @@ -1162,7 +1190,7 @@ command { service = "ChanServ"; name = "SYNC"; command = "chanserv/sync"; } * Used for changing the channel topic. Usedful in conjunction with chanserv/set/topiclock. */ module { name = "cs_topic" } -command { service = "ChanServ"; name = "TOPIC"; command = "chanserv/topic"; } +command { service = "ChanServ"; name = "TOPIC"; command = "chanserv/topic"; group = "chanserv/management" } /* * cs_unban @@ -1182,8 +1210,8 @@ command { service = "ChanServ"; name = "UNBAN"; command = "chanserv/unban"; } * Used for setting or removing your status modes on a channel. */ module { name = "cs_updown" } -command { service = "ChanServ"; name = "DOWN"; command = "chanserv/down"; } -command { service = "ChanServ"; name = "UP"; command = "chanserv/up"; } +command { service = "ChanServ"; name = "DOWN"; command = "chanserv/down"; group = "chanserv/status" } +command { service = "ChanServ"; name = "UP"; command = "chanserv/up"; group = "chanserv/status" } /* * cs_xop @@ -1194,17 +1222,17 @@ command { service = "ChanServ"; name = "UP"; command = "chanserv/up"; } * Used for giving users access in channels. */ module { name = "cs_xop" } -command { service = "ChanServ"; name = "QOP"; command = "chanserv/qop"; } -command { service = "ChanServ"; name = "SOP"; command = "chanserv/sop"; } -command { service = "ChanServ"; name = "AOP"; command = "chanserv/aop"; } -command { service = "ChanServ"; name = "HOP"; command = "chanserv/hop"; } -command { service = "ChanServ"; name = "VOP"; command = "chanserv/vop"; } +command { service = "ChanServ"; name = "QOP"; command = "chanserv/qop"; group = "chanserv/access" } +command { service = "ChanServ"; name = "SOP"; command = "chanserv/sop"; group = "chanserv/access" } +command { service = "ChanServ"; name = "AOP"; command = "chanserv/aop"; group = "chanserv/access" } +command { service = "ChanServ"; name = "HOP"; command = "chanserv/hop"; group = "chanserv/access" } +command { service = "ChanServ"; name = "VOP"; command = "chanserv/vop"; group = "chanserv/access" } /* Use m_rewrite to rewrite the op, deop, etc. commands (see modules.conf). */ command { - service = "ChanServ"; name = "OWNER"; command = "rewrite" + service = "ChanServ"; name = "OWNER"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_souce = "OWNER $" @@ -1214,7 +1242,7 @@ command } command { - service = "ChanServ"; name = "DEOWNER"; command = "rewrite" + service = "ChanServ"; name = "DEOWNER"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_source = "DEOWNER $" @@ -1225,7 +1253,7 @@ command command { - service = "ChanServ"; name = "PROTECT"; command = "rewrite"; + service = "ChanServ"; name = "PROTECT"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_source = "PROTECT $" @@ -1235,7 +1263,7 @@ command } command { - service = "ChanServ"; name = "DEPROTECT"; command = "rewrite"; + service = "ChanServ"; name = "DEPROTECT"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_source = "DEPROTECT $" @@ -1246,7 +1274,7 @@ command command { - service = "ChanServ"; name = "OP"; command = "rewrite"; + service = "ChanServ"; name = "OP"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_source = "OP $" @@ -1257,7 +1285,7 @@ command command { - service = "ChanServ"; name = "DEOP"; command = "rewrite"; + service = "ChanServ"; name = "DEOP"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_source = "DEOP $" @@ -1269,7 +1297,7 @@ command /* HALFOP and DEHALFOP commands */ command { - service = "ChanServ"; name = "HALFOP"; command = "rewrite"; + service = "ChanServ"; name = "HALFOP"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_source = "HALFOP $" @@ -1280,7 +1308,7 @@ command } command { - service = "ChanServ"; name = "DEHALFOP"; command = "rewrite" + service = "ChanServ"; name = "DEHALFOP"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_source = "DEHALFOP $" @@ -1292,7 +1320,7 @@ command /* VOICE and DEVOICE commands */ command { - service = "ChanServ"; name = "VOICE"; command = "rewrite"; + service = "ChanServ"; name = "VOICE"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_source = "VOICE $" @@ -1303,7 +1331,7 @@ command command { - service = "ChanServ"; name = "DEVOICE"; command = "rewrite"; + service = "ChanServ"; name = "DEVOICE"; command = "rewrite"; group = "chanserv/status" rewrite = true rewrite_source = "DEVOICE $" diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf index 87cd2f03a..136d586cb 100644 --- a/data/nickserv.example.conf +++ b/data/nickserv.example.conf @@ -300,6 +300,17 @@ nickserv * Sane defaults are provided below that do not need to be edited unless you wish to change the default behaviour. */ +/* Command group configuration for NickServ. + * + * Commands may optionally be placed into groups to make NickServ's HELP output easier to understand. + * Remove the following groups to use the old behavior of simply listing all NickServ commands from HELP. + */ +command_group +{ + name = "nickserv/admin"; + description = "Servies Operator commands" +} + /* Give it a help command */ command { service = "NickServ"; name = "HELP"; command = "generic/help"; } @@ -361,7 +372,7 @@ command { service = "NickServ"; name = "DROP"; command = "nickserv/drop"; } * Used for getting registered accounts by searching for emails. */ module { name = "ns_getemail" } -command { service = "NickServ"; name = "GETEMAIL"; command = "nickserv/getemail"; permission = "nickserv/getemail"; } +command { service = "NickServ"; name = "GETEMAIL"; command = "nickserv/getemail"; permission = "nickserv/getemail"; group = "nickserv/admin" } /* * ns_getpass @@ -395,7 +406,7 @@ command { service = "NickServ"; name = "UNGROUP"; command = "nickserv/ungroup"; * Used for identifying to accounts. */ module { name = "ns_identify" } -command { service = "NickServ"; name = "ID"; command = "nickserv/identify"; } +command { service = "NickServ"; name = "ID"; command = "nickserv/identify"; hide = true } command { service = "NickServ"; name = "IDENTIFY"; command = "nickserv/identify"; } /* @@ -416,7 +427,7 @@ command { service = "NickServ"; name = "INFO"; command = "nickserv/info"; } * Used for retrieving and searching the registered account list. */ module { name = "ns_list" } -command { service = "NickServ"; name = "LIST"; command = "nickserv/list"; } +command { service = "NickServ"; name = "LIST"; command = "nickserv/list"; command = "nickserv/admin" } /* * ns_logout @@ -486,42 +497,42 @@ command { service = "NickServ"; name = "RESETPASS"; command = "nickserv/resetpas module { name = "ns_set" } command { service = "NickServ"; name = "SET"; command = "nickserv/set"; } -command { service = "NickServ"; name = "SASET"; command = "nickserv/saset"; permission = "nickserv/saset/" } +command { service = "NickServ"; name = "SASET"; command = "nickserv/saset"; permission = "nickserv/saset/"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET AUTOOP"; command = "nickserv/set/autoop"; } -command { service = "NickServ"; name = "SASET AUTOOP"; command = "nickserv/saset/autoop"; permission = "nickserv/saset/autoop"; } +command { service = "NickServ"; name = "SASET AUTOOP"; command = "nickserv/saset/autoop"; permission = "nickserv/saset/autoop"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET DISPLAY"; command = "nickserv/set/display"; } -command { service = "NickServ"; name = "SASET DISPLAY"; command = "nickserv/saset/display"; permission = "nickserv/saset/display"; } +command { service = "NickServ"; name = "SASET DISPLAY"; command = "nickserv/saset/display"; permission = "nickserv/saset/display"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET EMAIL"; command = "nickserv/set/email"; } -command { service = "NickServ"; name = "SASET EMAIL"; command = "nickserv/saset/email"; permission = "nickserv/saset/email"; } +command { service = "NickServ"; name = "SASET EMAIL"; command = "nickserv/saset/email"; permission = "nickserv/saset/email"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET GREET"; command = "nickserv/set/greet"; } -command { service = "NickServ"; name = "SASET GREET"; command = "nickserv/saset/greet"; permission = "nickserv/saset/greet"; } +command { service = "NickServ"; name = "SASET GREET"; command = "nickserv/saset/greet"; permission = "nickserv/saset/greet"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET HIDE"; command = "nickserv/set/hide"; } -command { service = "NickServ"; name = "SASET HIDE"; command = "nickserv/saset/hide"; permission = "nickserv/saset/hide"; } +command { service = "NickServ"; name = "SASET HIDE"; command = "nickserv/saset/hide"; permission = "nickserv/saset/hide"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET KILL"; command = "nickserv/set/kill"; } -command { service = "NickServ"; name = "SASET KILL"; command = "nickserv/saset/kill"; permission = "nickserv/saset/kill"; } +command { service = "NickServ"; name = "SASET KILL"; command = "nickserv/saset/kill"; permission = "nickserv/saset/kill"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET LANGUAGE"; command = "nickserv/set/language"; } -command { service = "NickServ"; name = "SASET LANGUAGE"; command = "nickserv/saset/language"; permission = "nickserv/saset/language"; } +command { service = "NickServ"; name = "SASET LANGUAGE"; command = "nickserv/saset/language"; permission = "nickserv/saset/language"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET MESSAGE"; command = "nickserv/set/message"; } -command { service = "NickServ"; name = "SASET MESSAGE"; command = "nickserv/saset/message"; permission = "nickserv/saset/message"; } +command { service = "NickServ"; name = "SASET MESSAGE"; command = "nickserv/saset/message"; permission = "nickserv/saset/message"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET PASSWORD"; command = "nickserv/set/password"; } -command { service = "NickServ"; name = "SASET PASSWORD"; command = "nickserv/saset/password"; permission = "nickserv/saset/password"; } +command { service = "NickServ"; name = "SASET PASSWORD"; command = "nickserv/saset/password"; permission = "nickserv/saset/password"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET PRIVATE"; command = "nickserv/set/private"; } -command { service = "NickServ"; name = "SASET PRIVATE"; command = "nickserv/saset/private"; permission = "nickserv/saset/private"; } +command { service = "NickServ"; name = "SASET PRIVATE"; command = "nickserv/saset/private"; permission = "nickserv/saset/private"; group = "nickserv/admin" } command { service = "NickServ"; name = "SET SECURE"; command = "nickserv/set/secure"; } -command { service = "NickServ"; name = "SASET SECURE"; command = "nickserv/saset/secure"; permission = "nickserv/saset/secure"; } +command { service = "NickServ"; name = "SASET SECURE"; command = "nickserv/saset/secure"; permission = "nickserv/saset/secure"; group = "nickserv/admin" } -command { service = "NickServ"; name = "SASET NOEXPIRE"; command = "nickserv/saset/noexpire"; permission = "nickserv/saset/noexpire" } +command { service = "NickServ"; name = "SASET NOEXPIRE"; command = "nickserv/saset/noexpire"; permission = "nickserv/saset/noexpire"; group = "nickserv/admin" } /* * ns_set_misc @@ -555,8 +566,8 @@ command { service = "NickServ"; name = "STATUS"; command = "nickserv/status"; } * Used to suspend and unsuspend nicknames. Suspended nicknames can not be used but their settings are stored. */ module { name = "ns_suspend" } -command { service = "NickServ"; name = "SUSPEND"; command = "nickserv/suspend"; permission = "nickserv/suspend"; } -command { service = "NickServ"; name = "UNSUSPEND"; command = "nickserv/unsuspend"; permission = "nickserv/suspend"; } +command { service = "NickServ"; name = "SUSPEND"; command = "nickserv/suspend"; permission = "nickserv/suspend"; group = "nickserv/admin" } +command { service = "NickServ"; name = "UNSUSPEND"; command = "nickserv/unsuspend"; permission = "nickserv/suspend"; group = "nickserv/admin" } /* * ns_update diff --git a/include/bots.h b/include/bots.h index ba6fbaab6..afffc7689 100644 --- a/include/bots.h +++ b/include/bots.h @@ -122,8 +122,9 @@ class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializab * @param cname The command name * @param sname The service name * @param permission Permission required to execute the command, if any + * @return The commandinfo for the newly created command */ - void SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission = ""); + CommandInfo& SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission = ""); /** Get command info for a command * @param cname The command name diff --git a/include/commands.h b/include/commands.h index b6b2dfc1f..9f7782102 100644 --- a/include/commands.h +++ b/include/commands.h @@ -25,17 +25,26 @@ enum CommandFlag CFLAG_REQUIRE_USER }; +struct CommandGroup +{ + Anope::string name, description; +}; + /* Used in BotInfo::commands */ struct CommandInfo { typedef Anope::map<CommandInfo> map; - CommandInfo() : prepend_channel(false) { } + CommandInfo() : hide(false), prepend_channel(false) { } /* Service name of the command */ Anope::string name; /* Permission required to execute the command */ Anope::string permission; + /* Group this command is in */ + Anope::string group; + /* whether or not to hide this command in help output */ + bool hide; /* Only used with fantasy */ bool prepend_channel; }; diff --git a/include/config.h b/include/config.h index f0c293e50..c69bc7b76 100644 --- a/include/config.h +++ b/include/config.h @@ -678,6 +678,8 @@ class CoreExport ServerConfig /* Map of fantasy commands */ CommandInfo::map Fantasy; + + std::vector<CommandGroup> CommandGroups; }; /** This class can be used on its own to represent an exception, or derived to represent a module-specific exception. 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> ¶ms) 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" diff --git a/src/bots.cpp b/src/bots.cpp index b796828a4..ef8514c87 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -251,12 +251,13 @@ void BotInfo::OnMessage(User *u, const Anope::string &message) RunCommand(source, message); } -void BotInfo::SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission) +CommandInfo& BotInfo::SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission) { CommandInfo ci; ci.name = sname; ci.permission = permission; this->commands[cname] = ci; + return this->commands[cname]; } CommandInfo *BotInfo::GetCommand(const Anope::string &cname) diff --git a/src/config.cpp b/src/config.cpp index 6c99e9c6e..bdd7180da 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -819,6 +819,8 @@ static bool DoCommands(ServerConfig *config, const Anope::string &, const Anope: Anope::string name = values[1].GetValue(); Anope::string command = values[2].GetValue(); Anope::string permission = values[3].GetValue(); + Anope::string group = values[4].GetValue(); + bool hide = values[5].GetBool(); ValueItem vi(service); if (!ValidateNotEmpty(config, "command", "service", vi)) @@ -839,7 +841,9 @@ static bool DoCommands(ServerConfig *config, const Anope::string &, const Anope: if (bi->commands.count(name)) throw ConfigException("Command name " + name + " already exists on " + bi->nick); - bi->SetCommand(name, command, permission); + CommandInfo &ci = bi->SetCommand(name, command, permission); + ci.group = group; + ci.hide = hide; return true; } @@ -1026,6 +1030,35 @@ static bool DoneFantasy(ServerConfig *config, const Anope::string &) /*************************************************************************/ +static bool InitCommandGroups(ServerConfig *config, const Anope::string &) +{ + config->CommandGroups.clear(); + return true; +} + +static bool DoCommandGroups(ServerConfig *config, const Anope::string &, const Anope::string *, ValueList &values, int *) +{ + Anope::string name = values[0].GetValue(); + Anope::string description = values[1].GetValue(); + + if (name.empty() || description.empty()) + return true; + + CommandGroup gr; + gr.name = name; + gr.description = description; + + config->CommandGroups.push_back(gr); + return true; +} + +static bool DoneCommandGroups(ServerConfig *config, const Anope::string &) +{ + return true; +} + +/*************************************************************************/ + ConfigurationFile::ConfigurationFile(const Anope::string &n, bool e) : name(n), executable(e), fp(NULL) { } @@ -1340,9 +1373,9 @@ ConfigItems::ConfigItems(ServerConfig *conf) {DT_STRING, DT_STRING, DT_INTEGER, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN, DT_BOOLEAN}, InitLogs, DoLogs, DoneLogs}, {"command", - {"service", "name", "command", "permission", ""}, - {"", "", "", "", ""}, - {DT_STRING, DT_STRING, DT_STRING, DT_STRING}, + {"service", "name", "command", "permission", "group", "hide", ""}, + {"", "", "", "", "", "no", ""}, + {DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN}, InitCommands, DoCommands, DoneCommands}, {"privilege", {"name", "desc", "rank", ""}, @@ -1354,6 +1387,11 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"", "", "", "yes", ""}, {DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN}, InitFantasy, DoFantasy, DoneFantasy}, + {"command_group", + {"name", "description", ""}, + {"", "", ""}, + {DT_STRING, DT_STRING}, + InitCommandGroups, DoCommandGroups, DoneCommandGroups}, {"", {""}, {""}, |