From 9ec18a3b020932eee6242c878149c484f49b13cb Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 4 Aug 2011 21:59:01 -0400 Subject: Added a command:permission setting --- data/commands.example.conf | 156 +++++++++++++++++----------------- data/example.conf | 20 +---- include/bots.h | 15 +++- include/commands.h | 17 ++-- include/config.h | 4 - include/services.h | 1 + modules/core/bs_bot.cpp | 6 +- modules/core/cs_list.cpp | 6 -- modules/core/cs_saset.cpp | 10 ++- modules/core/cs_saset_noexpire.cpp | 4 +- modules/core/cs_set.cpp | 8 +- modules/core/cs_set_bantype.cpp | 6 +- modules/core/cs_set_description.cpp | 6 +- modules/core/cs_set_founder.cpp | 10 +-- modules/core/cs_set_keeptopic.cpp | 6 +- modules/core/cs_set_opnotice.cpp | 6 +- modules/core/cs_set_peace.cpp | 6 +- modules/core/cs_set_persist.cpp | 6 +- modules/core/cs_set_private.cpp | 6 +- modules/core/cs_set_restricted.cpp | 6 +- modules/core/cs_set_secure.cpp | 6 +- modules/core/cs_set_securefounder.cpp | 6 +- modules/core/cs_set_secureops.cpp | 6 +- modules/core/cs_set_signkick.cpp | 6 +- modules/core/cs_set_successor.cpp | 10 +-- modules/core/cs_set_topiclock.cpp | 6 +- modules/core/cs_suspend.cpp | 4 +- modules/core/db_mysql.cpp | 2 +- modules/core/gl_global.cpp | 2 +- modules/core/help.cpp | 40 +++++---- modules/core/hs_del.cpp | 4 +- modules/core/hs_list.cpp | 2 +- modules/core/hs_set.cpp | 4 +- modules/core/ms_sendall.cpp | 2 +- modules/core/ms_staff.cpp | 2 +- modules/core/ns_getemail.cpp | 2 +- modules/core/ns_getpass.cpp | 2 +- modules/core/ns_list.cpp | 6 -- modules/core/ns_saset.cpp | 15 ++-- modules/core/ns_saset_noexpire.cpp | 2 +- modules/core/ns_set.cpp | 11 ++- modules/core/ns_set_autoop.cpp | 4 +- modules/core/ns_set_email.cpp | 4 +- modules/core/ns_set_greet.cpp | 4 +- modules/core/ns_set_hide.cpp | 4 +- modules/core/ns_set_kill.cpp | 4 +- modules/core/ns_set_language.cpp | 4 +- modules/core/ns_set_message.cpp | 4 +- modules/core/ns_set_private.cpp | 4 +- modules/core/ns_set_secure.cpp | 4 +- modules/core/ns_suspend.cpp | 4 +- modules/core/os_akill.cpp | 2 +- modules/core/os_chankill.cpp | 2 +- modules/core/os_config.cpp | 2 +- modules/core/os_forbid.cpp | 2 +- modules/core/os_ignore.cpp | 2 +- modules/core/os_jupe.cpp | 2 +- modules/core/os_kick.cpp | 2 +- modules/core/os_kill.cpp | 2 +- modules/core/os_mode.cpp | 4 +- modules/core/os_modinfo.cpp | 10 ++- modules/core/os_module.cpp | 6 +- modules/core/os_news.cpp | 2 +- modules/core/os_noop.cpp | 2 +- modules/core/os_oline.cpp | 2 +- modules/core/os_oper.cpp | 2 +- modules/core/os_reload.cpp | 2 +- modules/core/os_session.cpp | 2 +- modules/core/os_set.cpp | 2 +- modules/core/os_shutdown.cpp | 6 +- modules/core/os_stats.cpp | 2 +- modules/core/os_svsnick.cpp | 2 +- modules/core/os_sxline.cpp | 8 +- modules/core/os_update.cpp | 2 +- modules/extra/cs_set_misc.cpp | 4 +- modules/extra/hs_request.cpp | 6 +- modules/extra/m_async_commands.cpp | 2 +- modules/extra/ns_set_misc.cpp | 4 +- modules/extra/os_defcon.cpp | 2 +- src/bots.cpp | 35 +++++++- src/command.cpp | 7 +- src/config.cpp | 11 ++- 82 files changed, 329 insertions(+), 297 deletions(-) diff --git a/data/commands.example.conf b/data/commands.example.conf index 03a5b01f6..6290dae6e 100644 --- a/data/commands.example.conf +++ b/data/commands.example.conf @@ -5,6 +5,8 @@ * In Anope modules can provide (multiple) commands, each of which has a unique command name. Once these modules * are loaded you can then configure the commands to be added to any client you like with any name you like. * + * Additionally, you may provide a permission name that must be in the opertype of users executing the command. + * * Sane defaults are below. */ @@ -62,7 +64,7 @@ module { name = "cs_kick" } command { service = "ChanServ"; name = "KICK"; command = "chanserv/kick"; } command { service = "ChanServ"; name = "K"; command = "chanserv/kick"; } module { name = "cs_list" } -command { service = "ChanServ"; name = "LIST"; command = "chanserv/list"; } +command { service = "ChanServ"; name = "LIST"; command = "chanserv/list"; permission = "chanserv/list"; } module { name = "cs_mode" } command { service = "ChanServ"; name = "MODE"; command = "chanserv/mode"; } module { name = "cs_modes" } @@ -81,59 +83,59 @@ command { service = "ChanServ"; name = "REGISTER"; command = "chanserv/register" module { name = "cs_set" } command { service = "ChanServ"; name = "SET"; command = "chanserv/set"; } module { name = "cs_saset" } -command { service = "ChanServ"; name = "SASET"; command = "chanserv/saset"; } +command { service = "ChanServ"; name = "SASET"; command = "chanserv/saset"; permission = "chanserv/saset"; } module { name = "cs_set_bantype" } command { service = "ChanServ"; name = "SET BANTYPE"; command = "chanserv/set/bantype"; } -command { service = "ChanServ"; name = "SASET BANTYPE"; command = "chanserv/saset/bantype"; } +command { service = "ChanServ"; name = "SASET BANTYPE"; command = "chanserv/saset/bantype"; permission = "chanserv/saset/bantype"; } module { name = "cs_set_description" } command { service = "ChanServ"; name = "SET DESCRIPTION"; command = "chanserv/set/description"; } command { service = "ChanServ"; name = "SET DESC"; command = "chanserv/set/description"; } -command { service = "ChanServ"; name = "SASET DESCRIPTION"; command = "chanserv/saset/description"; } -command { service = "ChanServ"; name = "SASET DESC"; command = "chanserv/saset/description"; } +command { service = "ChanServ"; name = "SASET DESCRIPTION"; command = "chanserv/saset/description"; permission = "chanserv/saset/description"; } +command { service = "ChanServ"; name = "SASET DESC"; command = "chanserv/saset/description"; permission = "chanserv/saset/desc"; } module { name = "cs_set_founder" } command { service = "ChanServ"; name = "SET FOUNDER"; command = "chanserv/set/founder"; } -command { service = "ChanServ"; name = "SASET FOUNDER"; command = "chanserv/saset/founder"; } +command { service = "ChanServ"; name = "SASET FOUNDER"; command = "chanserv/saset/founder"; permission = "chanserv/saset/founder"; } module { name = "cs_set_keeptopic" } command { service = "ChanServ"; name = "SET KEEPTOPIC"; command = "chanserv/set/keeptopic"; } -command { service = "ChanServ"; name = "SASET KEEPTOPIC"; command = "chanserv/saset/keeptopic"; } +command { service = "ChanServ"; name = "SASET KEEPTOPIC"; command = "chanserv/saset/keeptopic"; permission = "chanserv/saset/keeptopic"; } module { name = "cs_set_opnotice" } command { service = "ChanServ"; name = "SET OPNOTICE"; command = "chanserv/set/opnotice"; } -command { service = "ChanServ"; name = "SASET OPNOTICE"; command = "chanserv/saset/opnotice"; } +command { service = "ChanServ"; name = "SASET OPNOTICE"; command = "chanserv/saset/opnotice"; permission = "chanserv/saset/optnotice"; } module { name = "cs_set_peace" } command { service = "ChanServ"; name = "SET PEACE"; command = "chanserv/set/peace"; } -command { service = "ChanServ"; name = "SASET PEACE"; command = "chanserv/saset/peace"; } +command { service = "ChanServ"; name = "SASET PEACE"; command = "chanserv/saset/peace"; permission = "chanserv/saset/peace"; } module { name = "cs_set_persist" } command { service = "ChanServ"; name = "SET PERSIST"; command = "chanserv/set/persist"; } -command { service = "ChanServ"; name = "SASET PERSIST"; command = "chanserv/saset/persist"; } +command { service = "ChanServ"; name = "SASET PERSIST"; command = "chanserv/saset/persist"; permission = "chanserv/saset/persist"; } module { name = "cs_set_private" } command { service = "ChanServ"; name = "SET PRIVATE"; command = "chanserv/set/private"; } -command { service = "ChanServ"; name = "SASET PRIVATE"; command = "chanserv/saset/private"; } +command { service = "ChanServ"; name = "SASET PRIVATE"; command = "chanserv/saset/private"; permission = "chanserv/saset/private"; } module { name = "cs_set_restricted" } command { service = "ChanServ"; name = "SET RESTRICTED"; command = "chanserv/set/restricted"; } -command { service = "ChanServ"; name = "SASET RESTRICTED"; command = "chanserv/saset/restricted"; } +command { service = "ChanServ"; name = "SASET RESTRICTED"; command = "chanserv/saset/restricted"; permission = "chanserv/saset/restricted"; } module { name = "cs_set_secure" } command { service = "ChanServ"; name = "SET SECURE"; command = "chanserv/set/secure"; } -command { service = "ChanServ"; name = "SASET SECURE"; command = "chanserv/saset/secure"; } +command { service = "ChanServ"; name = "SASET SECURE"; command = "chanserv/saset/secure"; permission = "chanserv/saset/secure"; } module { name = "cs_set_securefounder" } command { service = "ChanServ"; name = "SET SECUREFOUNDER"; command = "chanserv/set/securefounder"; } -command { service = "ChanServ"; name = "SASET SECUREFOUNDER"; command = "chanserv/saset/securefounder"; } +command { service = "ChanServ"; name = "SASET SECUREFOUNDER"; command = "chanserv/saset/securefounder"; permission = "chanserv/saset/securefounder"; } module { name = "cs_set_secureops" } command { service = "ChanServ"; name = "SET SECUREOPS"; command = "chanserv/set/secureops"; } -command { service = "ChanServ"; name = "SASET SECUREOPS"; command = "chanserv/saset/secureops"; } +command { service = "ChanServ"; name = "SASET SECUREOPS"; command = "chanserv/saset/secureops"; permission = "chanserv/saset/secureops"; } module { name = "cs_set_signkick" } command { service = "ChanServ"; name = "SET SIGNKICK"; command = "chanserv/set/signkick"; } -command { service = "ChanServ"; name = "SASET SIGNKICK"; command = "chanserv/saset/signkick"; } +command { service = "ChanServ"; name = "SASET SIGNKICK"; command = "chanserv/saset/signkick"; permission = "chanserv/saset/signkick"; } module { name = "cs_set_successor" } command { service = "ChanServ"; name = "SET SUCCESSOR"; command = "chanserv/set/successor"; } -command { service = "ChanServ"; name = "SASET SUCCESSOR"; command = "chanserv/saset/successor"; } +command { service = "ChanServ"; name = "SASET SUCCESSOR"; command = "chanserv/saset/successor"; permission = "chanserv/saset/successor"; } module { name = "cs_set_topiclock" } command { service = "ChanServ"; name = "SET TOPICLOCK"; command = "chanserv/set/topiclock"; } -command { service = "ChanServ"; name = "SASET TOPICLOCK"; command = "chanserv/saset/topiclock"; } +command { service = "ChanServ"; name = "SASET TOPICLOCK"; command = "chanserv/saset/topiclock"; permission = "chanserv/saset/topiclock"; } module { name = "cs_saset_noexpire" } -command { service = "ChanServ"; name = "SASET NOEXPIRE"; command = "chanserv/saset/noexpire"; } +command { service = "ChanServ"; name = "SASET NOEXPIRE"; command = "chanserv/saset/noexpire"; permission = "chanserv/saset/noexpire"; } module { name = "cs_suspend" } -command { service = "ChanServ"; name = "SUSPEND"; command = "chanserv/suspend"; } -command { service = "ChanServ"; name = "UNSUSPEND"; command = "chanserv/unsuspend"; } +command { service = "ChanServ"; name = "SUSPEND"; command = "chanserv/suspend"; permission = "chanserv/suspend"; } +command { service = "ChanServ"; name = "UNSUSPEND"; command = "chanserv/unsuspend"; permission = "chanserv/suspend"; } module { name = "cs_topic" } command { service = "ChanServ"; name = "TOPIC"; command = "chanserv/topic"; } module { name = "cs_unban" } @@ -146,22 +148,22 @@ command { service = "ChanServ"; name = "HOP"; command = "chanserv/hop"; } command { service = "ChanServ"; name = "VOP"; command = "chanserv/vop"; } module { name = "gl_global" } -command { service = "Global"; name = "GLOBAL"; command = "global/global"; } +command { service = "Global"; name = "GLOBAL"; command = "global/global"; permission = "global/global"; } module { name = "hs_del" } -command { service = "HostServ"; name = "DEL"; command = "hostserv/del"; } -command { service = "HostServ"; name = "DELALL"; command = "hostserv/delall"; } +command { service = "HostServ"; name = "DEL"; command = "hostserv/del"; permission = "hostserv/del"; } +command { service = "HostServ"; name = "DELALL"; command = "hostserv/delall"; permission = "hostserv/del"; } module { name = "hs_group" } command { service = "HostServ"; name = "GROUP"; command = "hostserv/group"; } module { name = "hs_list" } -command { service = "HostServ"; name = "LIST"; command = "hostserv/list"; } +command { service = "HostServ"; name = "LIST"; command = "hostserv/list"; permission = "hostserv/list"; } module { name = "hs_off" } command { service = "HostServ"; name = "OFF"; command = "hostserv/off"; } module { name = "hs_on" } command { service = "HostServ"; name = "ON"; command = "hostserv/on"; } module { name = "hs_set" } -command { service = "HostServ"; name = "SET"; command = "hostserv/set"; } -command { service = "HostServ"; name = "SETALL"; command = "hostserv/setall"; } +command { service = "HostServ"; name = "SET"; command = "hostserv/set"; permission = "hostserv/set"; } +command { service = "HostServ"; name = "SETALL"; command = "hostserv/setall"; permission = "hostserv/set"; } module { name = "ms_cancel" } command { service = "MemoServ"; name = "CANCEL"; command = "memoserv/cancel"; } @@ -182,11 +184,11 @@ command { service = "MemoServ"; name = "RSEND"; command = "memoserv/rsend"; } module { name = "ms_send" } command { service = "MemoServ"; name = "SEND"; command = "memoserv/send"; } module { name = "ms_sendall" } -command { service = "MemoServ"; name = "SENDALL"; command = "memoserv/sendall"; } +command { service = "MemoServ"; name = "SENDALL"; command = "memoserv/sendall"; permission = "memoserv/sendall"; } module { name = "ms_set" } command { service = "MemoServ"; name = "SET"; command = "memoserv/set"; } module { name = "ms_staff" } -command { service = "MemoServ"; name = "STAFF"; command = "memoserv/staff"; } +command { service = "MemoServ"; name = "STAFF"; command = "memoserv/staff"; permission = "memoserv/staff"; } module { name = "ns_access" } command { service = "NickServ"; name = "ACCESS"; command = "nickserv/access"; } @@ -199,9 +201,9 @@ command { service = "NickServ"; name = "CERT"; command = "nickserv/cert"; } module { name = "ns_drop" } command { service = "NickServ"; name = "DROP"; command = "nickserv/drop"; } module { name = "ns_getemail" } -command { service = "NickServ"; name = "GETEMAIL"; command = "nickserv/getemail"; } +command { service = "NickServ"; name = "GETEMAIL"; command = "nickserv/getemail"; permission = "nickserv/getemail"; } module { name = "ns_getpass" } -command { service = "NickServ"; name = "GETPASS"; command = "nickserv/getpass"; } +command { service = "NickServ"; name = "GETPASS"; command = "nickserv/getpass"; permission = "nickserv/getpass"; } module { name = "ns_ghost" } command { service = "NickServ"; name = "GHOST"; command = "nickserv/ghost"; } module { name = "ns_group" } @@ -237,103 +239,103 @@ command { service = "NickServ"; name = "SET DISPLAY"; command = "nickserv/set/di command { service = "NickServ"; name = "SET PASSWORD"; command = "nickserv/set/password"; } module { name = "ns_set_autoop" } command { service = "NickServ"; name = "SET AUTOOP"; command = "nickserv/set/autoop"; } -command { service = "NickServ"; name = "SASET AUTOOP"; command = "nickserv/saset/autoop"; } +command { service = "NickServ"; name = "SASET AUTOOP"; command = "nickserv/saset/autoop"; permission = "nickserv/saset/autoop"; } module { name = "ns_set_email" } command { service = "NickServ"; name = "SET EMAIL"; command = "nickserv/set/email"; } -command { service = "NickServ"; name = "SASET EMAIL"; command = "nickserv/saset/email"; } +command { service = "NickServ"; name = "SASET EMAIL"; command = "nickserv/saset/email"; permission = "nickserv/saset/email"; } module { name = "ns_set_greet" } command { service = "NickServ"; name = "SET GREET"; command = "nickserv/set/greet"; } -command { service = "NickServ"; name = "SASET GREET"; command = "nickserv/saset/greet"; } +command { service = "NickServ"; name = "SASET GREET"; command = "nickserv/saset/greet"; permission = "nickserv/saset/greet"; } module { name = "ns_set_hide" } command { service = "NickServ"; name = "SET HIDE"; command = "nickserv/set/hide"; } -command { service = "NickServ"; name = "SASET HIDE"; command = "nickserv/saset/hide"; } +command { service = "NickServ"; name = "SASET HIDE"; command = "nickserv/saset/hide"; permission = "nickserv/saset/hide"; } module { name = "ns_set_kill" } command { service = "NickServ"; name = "SET KILL"; command = "nickserv/set/kill"; } -command { service = "NickServ"; name = "SASET KILL"; command = "nickserv/saset/kill"; } +command { service = "NickServ"; name = "SASET KILL"; command = "nickserv/saset/kill"; permission = "nickserv/saset/kill"; } module { name = "ns_set_language" } command { service = "NickServ"; name = "SET LANGUAGE"; command = "nickserv/set/language"; } -command { service = "NickServ"; name = "SASET LANGUAGE"; command = "nickserv/saset/language"; } +command { service = "NickServ"; name = "SASET LANGUAGE"; command = "nickserv/saset/language"; permission = "nickserv/saset/language"; } module { name = "ns_set_message" } command { service = "NickServ"; name = "SET MESSAGE"; command = "nickserv/set/message"; } -command { service = "NickServ"; name = "SASET MESSAGE"; command = "nickserv/saset/message"; } +command { service = "NickServ"; name = "SASET MESSAGE"; command = "nickserv/saset/message"; permission = "nickserv/saset/message"; } module { name = "ns_set_private" } command { service = "NickServ"; name = "SET PRIVATE"; command = "nickserv/set/private"; } -command { service = "NickServ"; name = "SASET PRIVATE"; command = "nickserv/saset/private"; } +command { service = "NickServ"; name = "SASET PRIVATE"; command = "nickserv/saset/private"; permission = "nickserv/saset/private"; } module { name = "ns_set_secure" } command { service = "NickServ"; name = "SET SECURE"; command = "nickserv/set/secure"; } -command { service = "NickServ"; name = "SASET SECURE"; command = "nickserv/saset/secure"; } +command { service = "NickServ"; name = "SASET SECURE"; command = "nickserv/saset/secure"; permission = "nickserv/saset/secure"; } module { name = "ns_saset_noexpire" } -command { service = "NickServ"; name = "SASET NOEXPIRE"; command = "nickserv/saset/noexpire"; } +command { service = "NickServ"; name = "SASET NOEXPIRE"; command = "nickserv/saset/noexpire"; permission = "nickserv/saset/noexpire" } module { name = "ns_sendpass" } -command { service = "NickServ"; name = "SENDPASS"; command = "nickserv/sendpass"; } +command { service = "NickServ"; name = "SENDPASS"; command = "nickserv/sendpass"; permission = "nickserv/sendpass"; } module { name = "ns_status" } command { service = "NickServ"; name = "STATUS"; command = "nickserv/status"; } module { name = "ns_suspend" } -command { service = "NickServ"; name = "SUSPEND"; command = "nickserv/suspend"; } -command { service = "NickServ"; name = "UNSUSPEND"; command = "nickserv/unsuspend"; } +command { service = "NickServ"; name = "SUSPEND"; command = "nickserv/suspend"; permission = "nickserv/suspend"; } +command { service = "NickServ"; name = "UNSUSPEND"; command = "nickserv/unsuspend"; permission = "nickserv/suspend"; } module { name = "ns_update" } command { service = "NickServ"; name = "UPDATE"; command = "nickserv/update"; } module { name = "os_akill" } -command { service = "OperServ"; name = "AKILL"; command = "operserv/akill"; } +command { service = "OperServ"; name = "AKILL"; command = "operserv/akill"; permission = "operserv/akill"; } module { name = "os_chankill" } -command { service = "OperServ"; name = "CHANKILL"; command = "operserv/chankill"; } +command { service = "OperServ"; name = "CHANKILL"; command = "operserv/chankill"; permission = "operserv/chankill"; } module { name = "os_list" } command { service = "OperServ"; name = "CHANLIST"; command = "operserv/chanlist"; } command { service = "OperServ"; name = "USERLIST"; command = "operserv/userlist"; } module { name = "os_config" } -command { service = "OperServ"; name = "CONFIG"; command = "operserv/config"; } +command { service = "OperServ"; name = "CONFIG"; command = "operserv/config"; permission = "operserv/config"; } module { name = "os_forbid" } -command { service = "OperServ"; name = "FORBID"; command = "operserv/forbid"; } +command { service = "OperServ"; name = "FORBID"; command = "operserv/forbid"; permission = "operserv/forbid"; } module { name = "os_ignore" } -command { service = "OperServ"; name = "IGNORE"; command = "operserv/ignore"; } +command { service = "OperServ"; name = "IGNORE"; command = "operserv/ignore"; permission = "operserv/ignore"; } module { name = "os_jupe" } -command { service = "OperServ"; name = "JUPE"; command = "operserv/jupe"; } +command { service = "OperServ"; name = "JUPE"; command = "operserv/jupe"; permission = "operserv/jupe"; } module { name = "os_kick" } -command { service = "OperServ"; name = "KICK"; command = "operserv/kick"; } +command { service = "OperServ"; name = "KICK"; command = "operserv/kick"; permission = "operserv/kick"; } module { name = "os_kill" } -command { service = "OperServ"; name = "KILL"; command = "operserv/kill"; } +command { service = "OperServ"; name = "KILL"; command = "operserv/kill"; permission = "operserv/kill"; } module { name = "os_login" } command { service = "OperServ"; name = "LOGIN"; command = "operserv/login"; } module { name = "os_mode" } -command { service = "OperServ"; name = "MODE"; command = "operserv/mode"; } -command { service = "OperServ"; name = "UMODE"; command = "operserv/umode"; } +command { service = "OperServ"; name = "MODE"; command = "operserv/mode"; permission = "operserv/mode"; } +command { service = "OperServ"; name = "UMODE"; command = "operserv/umode"; permission = "operserv/umode"; } module { name = "os_modinfo" } command { service = "OperServ"; name = "MODINFO"; command = "operserv/modinfo"; } -command { service = "OperServ"; name = "MODLIST"; command = "operserv/modlist"; } +command { service = "OperServ"; name = "MODLIST"; command = "operserv/modlist"; permission = "operserv/modlist"; } module { name = "os_module" } -command { service = "OperServ"; name = "MODLOAD"; command = "operserv/modload"; } -command { service = "OperServ"; name = "MODRELOAD"; command = "operserv/modreload"; } -command { service = "OperServ"; name = "MODUNLOAD"; command = "operserv/modunload"; } +command { service = "OperServ"; name = "MODLOAD"; command = "operserv/modload"; permission = "operserv/modload"; } +command { service = "OperServ"; name = "MODRELOAD"; command = "operserv/modreload"; permission = "operserv/modload"; } +command { service = "OperServ"; name = "MODUNLOAD"; command = "operserv/modunload"; permission = "operserv/modload"; } module { name = "os_news" } -command { service = "OperServ"; name = "LOGONNEWS"; command = "operserv/logonnews"; } -command { service = "OperServ"; name = "OPERNEWS"; command = "operserv/opernews"; } -command { service = "OperServ"; name = "RANDOMNEWS"; command = "operserv/randomnews"; } +command { service = "OperServ"; name = "LOGONNEWS"; command = "operserv/logonnews"; permission = "operserv/news"; } +command { service = "OperServ"; name = "OPERNEWS"; command = "operserv/opernews"; permission = "operserv/news"; } +command { service = "OperServ"; name = "RANDOMNEWS"; command = "operserv/randomnews"; permission = "operserv/news"; } module { name = "os_noop" } -command { service = "OperServ"; name = "NOOP"; command = "operserv/noop"; } +command { service = "OperServ"; name = "NOOP"; command = "operserv/noop"; permission = "operserv/noop"; } module { name = "os_oline" } -command { service = "OperServ"; name = "OLINE"; command = "operserv/oline"; } +command { service = "OperServ"; name = "OLINE"; command = "operserv/oline"; permission = "operserv/oline"; } module { name = "os_oper" } -command { service = "OperServ"; name = "OPER"; command = "operserv/oper"; } +command { service = "OperServ"; name = "OPER"; command = "operserv/oper"; permission = "operserv/oper"; } module { name = "os_reload" } -command { service = "OperServ"; name = "RELOAD"; command = "operserv/reload"; } +command { service = "OperServ"; name = "RELOAD"; command = "operserv/reload"; permission = "operserv/reload"; } module { name = "os_session" } -command { service = "OperServ"; name = "EXCEPTION"; command = "operserv/exception"; } -command { service = "OperServ"; name = "SESSION"; command = "operserv/session"; } +command { service = "OperServ"; name = "EXCEPTION"; command = "operserv/exception"; permission = "operserv/exception"; } +command { service = "OperServ"; name = "SESSION"; command = "operserv/session"; permission = "operserv/session"; } module { name = "os_set" } -command { service = "OperServ"; name = "SET"; command = "operserv/set"; } +command { service = "OperServ"; name = "SET"; command = "operserv/set"; permission = "operserv/set"; } module { name = "os_shutdown" } -command { service = "OperServ"; name = "QUIT"; command = "operserv/quit"; } -command { service = "OperServ"; name = "RESTART"; command = "operserv/restart"; } -command { service = "OperServ"; name = "SHUTDOWN"; command = "operserv/shutdown"; } +command { service = "OperServ"; name = "QUIT"; command = "operserv/quit"; permission = "operserv/quit"; } +command { service = "OperServ"; name = "RESTART"; command = "operserv/restart"; permission = "operserv/restart"; } +command { service = "OperServ"; name = "SHUTDOWN"; command = "operserv/shutdown"; permission = "operserv/shutdown"; } module { name = "os_stats" } -command { service = "OperServ"; name = "STATS"; command = "operserv/stats"; } +command { service = "OperServ"; name = "STATS"; command = "operserv/stats"; permission = "operserv/stats"; } module { name = "os_svsnick" } -command { service = "OperServ"; name = "SVSNICK"; command = "operserv/svsnick"; } +command { service = "OperServ"; name = "SVSNICK"; command = "operserv/svsnick"; permission = "operserv/svsnick"; } module { name = "os_sxline" } -command { service = "OperServ"; name = "SNLINE"; command = "operserv/snline"; } -command { service = "OperServ"; name = "SQLINE"; command = "operserv/sqline"; } -command { service = "OperServ"; name = "SZLINE"; command = "operserv/szline"; } +command { service = "OperServ"; name = "SNLINE"; command = "operserv/snline"; permission = "operserv/snline"; } +command { service = "OperServ"; name = "SQLINE"; command = "operserv/sqline"; permission = "operserv/sqline"; } +command { service = "OperServ"; name = "SZLINE"; command = "operserv/szline"; permission = "operserv/szline"; } module { name = "os_update" } -command { service = "OperServ"; name = "UPDATE"; command = "operserv/update"; } +command { service = "OperServ"; name = "UPDATE"; command = "operserv/update"; permission = "operserv/update"; } diff --git a/data/example.conf b/data/example.conf index 5f2956681..14065ddf4 100644 --- a/data/example.conf +++ b/data/example.conf @@ -719,13 +719,6 @@ chanserv */ inhabit = 15s - /* - * Limits the use of the ChanServ LIST command to IRC operators. - * - * This directive is optional. - */ - #listopersonly = yes - /* * The maximum number of channels to be returned for a ChanServ LIST command. */ @@ -1058,13 +1051,6 @@ nickserv */ #nogroupchange = yes - /* - * Limits the use of the NickServ LIST command to IRC operators. - * - * This directive is optional. - */ - #listopersonly = yes - /* * The maximum number of nicks to be returned for a NickServ LIST command. */ @@ -1375,7 +1361,9 @@ log * This block is recommended, as without it you will be unable to access most oper commands. * It replaces the old ServicesRoot directive amongst others. * - * Note that third party modules may add additional commands and privileges to this list. + * The command names below are defaults and are configured in commands.conf. If you configure + * additional commands with permissions, such as commands from third party modules, the permissions + * must be included in the opertype block before the command can be used. * * Available privileges: * botserv/administration - Can perform certain BotServ administrative tasks @@ -1418,7 +1406,7 @@ log * * global/global * - * operserv/news operserv/stats operserv/kick + * operserv/news operserv/stats operserv/kick operserv/exception * operserv/mode operserv/session operserv/modlist operserv/ignore * operserv/chankill operserv/akill operserv/sqline operserv/snline * operserv/szline operserv/oper operserv/config operserv/umode diff --git a/include/bots.h b/include/bots.h index 7508e4091..446287abf 100644 --- a/include/bots.h +++ b/include/bots.h @@ -13,7 +13,6 @@ class BotInfo; extern CoreExport Anope::insensitive_map BotListByNick; extern CoreExport Anope::map BotListByUID; typedef Anope::insensitive_map botinfo_map; -typedef Anope::insensitive_map command_map; /** Flags settable on a bot */ @@ -39,6 +38,7 @@ class CoreExport BotInfo : public User, public Flags uint32 chancount; time_t created; /* Birth date ;) */ time_t lastmsg; /* Last time we said something */ + typedef Anope::insensitive_map command_map; command_map commands; /* Commands, actual name to service name */ /** Create a new bot. @@ -100,6 +100,19 @@ class CoreExport BotInfo : public User, public Flags * @param message The users' message */ virtual void OnMessage(User *u, const Anope::string &message); + + /** Link a command name to a command in services + * @param cname The command name + * @param sname The service name + * @param permission Permission required to execute the command, if any + */ + void SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission = ""); + + /** Get command info for a command + * @param cname The command name + * @return A struct containing service name and permission + */ + CommandInfo *GetCommand(const Anope::string &cname); }; #endif // BOTS_H diff --git a/include/commands.h b/include/commands.h index 0ee9af226..227483f63 100644 --- a/include/commands.h +++ b/include/commands.h @@ -30,6 +30,12 @@ const Anope::string CommandFlagStrings[] = { "" }; +struct CommandInfo +{ + Anope::string name; + Anope::string permission; +}; + /* The source for a command */ struct CoreExport CommandSource { @@ -43,6 +49,8 @@ struct CoreExport CommandSource BotInfo *service; /* The actual name of the command being executed */ Anope::string command; + /* The permission of the command being executed */ + Anope::string permission; std::list reply; @@ -64,8 +72,6 @@ class CoreExport Command : public Service, public Flags size_t MaxParams; /* Minimum parameters required to use this command */ size_t MinParams; - /* Permission needed to use this comand */ - Anope::string permission; /* Module which owns us */ Module *module; @@ -77,7 +83,7 @@ class CoreExport Command : public Service, public Flags * @param max_params The maximum number of parameters the parser will create, after max_params, all will be combined into the last argument. * NOTE: If max_params is not set (default), there is no limit to the max number of params. */ - Command(Module *owner, const Anope::string &sname, size_t min_params, size_t max_params = 0, const Anope::string &spermission = ""); + Command(Module *owner, const Anope::string &sname, size_t min_params, size_t max_params = 0); virtual ~Command(); @@ -117,11 +123,6 @@ class CoreExport Command : public Service, public Flags * @param subcommand The subcommand the user tried to use */ virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand); - - /** Set which command permission (e.g. chanserv/forbid) is required for this command. - * @param reststr The permission required to successfully execute this command - */ - void SetPermission(const Anope::string &reststr); }; #endif // COMMANDS_H diff --git a/include/config.h b/include/config.h index 84ed2f8d3..6e686b13f 100644 --- a/include/config.h +++ b/include/config.h @@ -482,8 +482,6 @@ class CoreExport ServerConfig Anope::string NSEnforcerHost; /* How long before recovered nicks are released */ time_t NSReleaseTimeout; - /* /nickserv list is oper only */ - bool NSListOpersOnly; /* Max number of entries that can be returned from the list command */ unsigned NSListMax; /* Only allow usermode +a etc on real services admins */ @@ -523,8 +521,6 @@ class CoreExport ServerConfig Anope::string CSAutokickReason; /* Time ChanServ should stay in the channel to hold it to keep users from getting in */ time_t CSInhabit; - /* ChanServ's LIST command is oper only */ - bool CSListOpersOnly; /* Max number of entries allowed to be returned from the LIST command */ unsigned CSListMax; /* true to make ChanServ oper only */ diff --git a/include/services.h b/include/services.h index 0eeafc0e9..addaf6ae8 100644 --- a/include/services.h +++ b/include/services.h @@ -674,6 +674,7 @@ enum #include "users.h" #include "account.h" +#include "commands.h" #include "bots.h" struct LevelInfo diff --git a/modules/core/bs_bot.cpp b/modules/core/bs_bot.cpp index ec0bea734..7500d1926 100644 --- a/modules/core/bs_bot.cpp +++ b/modules/core/bs_bot.cpp @@ -314,7 +314,7 @@ class CommandBSBot : public Command if (cmd.equals_ci("ADD")) { // ADD nick user host real - 5 - if (!u->HasCommand("botserv/botserv/bot/add")) + if (!u->HasCommand("botserv/bot/add")) { source.Reply(ACCESS_DENIED); return; @@ -337,7 +337,7 @@ class CommandBSBot : public Command { // CHANGE oldn newn user host real - 6 // but only oldn and newn are required - if (!u->HasCommand("botserv/botserv/bot/change")) + if (!u->HasCommand("botserv/bot/change")) { source.Reply(ACCESS_DENIED); return; @@ -354,7 +354,7 @@ class CommandBSBot : public Command else if (cmd.equals_ci("DEL")) { // DEL nick - if (!u->HasCommand("botserv/botserv/bot/del")) + if (!u->HasCommand("botserv/bot/del")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/core/cs_list.cpp b/modules/core/cs_list.cpp index 639c23267..a79c047c4 100644 --- a/modules/core/cs_list.cpp +++ b/modules/core/cs_list.cpp @@ -33,12 +33,6 @@ class CommandCSList : public Command int count = 0, from = 0, to = 0; bool suspended = false, channoexpire = false; - if (Config->CSListOpersOnly && !u->HasMode(UMODE_OPER)) - { - source.Reply(ACCESS_DENIED); - return; - } - if (pattern[0] == '#') { Anope::string n1 = myStrGetToken(pattern.substr(1), '-', 0), /* Read FROM out */ diff --git a/modules/core/cs_saset.cpp b/modules/core/cs_saset.cpp index cb749a3c3..699c5bc2c 100644 --- a/modules/core/cs_saset.cpp +++ b/modules/core/cs_saset.cpp @@ -16,7 +16,7 @@ class CommandCSSASet : public Command { public: - CommandCSSASet(Module *creator) : Command(creator, "chanserv/saset", 2, 3, "chanserv/saset") + CommandCSSASet(Module *creator) : Command(creator, "chanserv/saset", 2, 3) { this->SetDesc(_("Forcefully set channel options and information")); this->SetSyntax(_("\037option\037 \037channel\037 \037parameters\037")); @@ -37,11 +37,13 @@ class CommandCSSASet : public Command " \n" "Available options:")); Anope::string this_name = source.command; - for (command_map::iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it) + for (BotInfo::command_map::iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it) { - if (it->first.find_ci(this_name + " ") == 0) + const Anope::string &c_name = it->first; + CommandInfo &info = it->second; + if (c_name.find_ci(this_name + " ") == 0) { - service_reference command(it->second); + service_reference command(info.name); if (command) { source.command = it->first; diff --git a/modules/core/cs_saset_noexpire.cpp b/modules/core/cs_saset_noexpire.cpp index 4a1caa449..1e085496f 100644 --- a/modules/core/cs_saset_noexpire.cpp +++ b/modules/core/cs_saset_noexpire.cpp @@ -16,7 +16,7 @@ class CommandCSSASetNoexpire : public Command { public: - CommandCSSASetNoexpire(Module *creator) : Command(creator, "chanserv/saset/noexpire", 2, 2, "chanserv/saset/noexpire") + CommandCSSASetNoexpire(Module *creator) : Command(creator, "chanserv/saset/noexpire", 2, 2) { this->SetDesc(_("Prevent the channel from expiring")); this->SetDesc(_("\037channel\037 {ON | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSASetNoexpire : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/core/cs_set.cpp b/modules/core/cs_set.cpp index 8b5ca1f61..65719ce91 100644 --- a/modules/core/cs_set.cpp +++ b/modules/core/cs_set.cpp @@ -37,11 +37,13 @@ class CommandCSSet : public Command " \n" "Available options:")); Anope::string this_name = source.command; - for (command_map::iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it) + for (BotInfo::command_map::iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it) { - if (it->first.find_ci(this_name + " ") == 0) + const Anope::string &c_name = it->first; + CommandInfo &info = it->second; + if (c_name.find_ci(this_name + " ") == 0) { - service_reference command(it->second); + service_reference command(info.name); if (command) { source.command = it->first; diff --git a/modules/core/cs_set_bantype.cpp b/modules/core/cs_set_bantype.cpp index 14b13a77b..94d2aa151 100644 --- a/modules/core/cs_set_bantype.cpp +++ b/modules/core/cs_set_bantype.cpp @@ -16,7 +16,7 @@ class CommandCSSetBanType : public Command { public: - CommandCSSetBanType(Module *creator, const Anope::string &cname = "chanserv/set/bantype", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetBanType(Module *creator, const Anope::string &cname = "chanserv/set/bantype") : Command(creator, cname, 2, 2) { this->SetDesc(_("Set how Services make bans on the channel")); this->SetSyntax(_("\037channel\037 \037bantype\037")); @@ -32,7 +32,7 @@ class CommandCSSetBanType : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -74,7 +74,7 @@ class CommandCSSetBanType : public Command class CommandCSSASetBanType : public CommandCSSetBanType { public: - CommandCSSASetBanType(Module *creator) : CommandCSSetBanType(creator, "chanserv/saset/bantype", "chanserv/saset/bantype") + CommandCSSASetBanType(Module *creator) : CommandCSSetBanType(creator, "chanserv/saset/bantype") { } }; diff --git a/modules/core/cs_set_description.cpp b/modules/core/cs_set_description.cpp index 3282f8144..5c2cd447d 100644 --- a/modules/core/cs_set_description.cpp +++ b/modules/core/cs_set_description.cpp @@ -16,7 +16,7 @@ class CommandCSSetDescription : public Command { public: - CommandCSSetDescription(Module *creator, const Anope::string &cname = "chanserv/set/description", const Anope::string &cpermission = "") : Command(creator, cname, 1, 2, cpermission) + CommandCSSetDescription(Module *creator, const Anope::string &cname = "chanserv/set/description") : Command(creator, cname, 1, 2) { this->SetDesc(_("Set the channel description")); this->SetSyntax(_("\037channel\037 [\037description\037]")); @@ -32,7 +32,7 @@ class CommandCSSetDescription : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -65,7 +65,7 @@ class CommandCSSetDescription : public Command class CommandCSSASetDescription : public CommandCSSetDescription { public: - CommandCSSASetDescription(Module *creator) : CommandCSSetDescription(creator, "chanserv/saset/description", "chanserv/saset/description") + CommandCSSASetDescription(Module *creator) : CommandCSSetDescription(creator, "chanserv/saset/description") { } }; diff --git a/modules/core/cs_set_founder.cpp b/modules/core/cs_set_founder.cpp index e71fd4d3e..2169af972 100644 --- a/modules/core/cs_set_founder.cpp +++ b/modules/core/cs_set_founder.cpp @@ -16,7 +16,7 @@ class CommandCSSetFounder : public Command { public: - CommandCSSetFounder(Module *creator, const Anope::string &cname = "chanserv/set/founder", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetFounder(Module *creator, const Anope::string &cname = "chanserv/set/founder") : Command(creator, cname, 2, 2) { this->SetDesc(_("Set the founder of a channel")); this->SetSyntax(_("\037channel\037 \037nick\037")); @@ -32,13 +32,13 @@ class CommandCSSetFounder : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; } - if (this->permission.empty() && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->HasPriv(u, CA_FOUNDER))) + if (source.permission.empty() && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->HasPriv(u, CA_FOUNDER))) { source.Reply(ACCESS_DENIED); return; @@ -59,7 +59,7 @@ class CommandCSSetFounder : public Command return; } - Log(!this->permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the founder to " << nc->display; + Log(!source.permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the founder to " << nc->display; ci->SetFounder(nc); @@ -81,7 +81,7 @@ class CommandCSSetFounder : public Command class CommandCSSASetFounder : public CommandCSSetFounder { public: - CommandCSSASetFounder(Module *creator) : CommandCSSetFounder(creator, "chanserv/saset/founder", "chanserv/saset/founder") + CommandCSSASetFounder(Module *creator) : CommandCSSetFounder(creator, "chanserv/saset/founder") { } }; diff --git a/modules/core/cs_set_keeptopic.cpp b/modules/core/cs_set_keeptopic.cpp index 0322987e4..05578a2e5 100644 --- a/modules/core/cs_set_keeptopic.cpp +++ b/modules/core/cs_set_keeptopic.cpp @@ -16,7 +16,7 @@ class CommandCSSetKeepTopic : public Command { public: - CommandCSSetKeepTopic(Module *creator, const Anope::string &cname = "chanserv/set/keeptopic", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetKeepTopic(Module *creator, const Anope::string &cname = "chanserv/set/keeptopic") : Command(creator, cname, 2, 2) { this->SetDesc(_("Retain topic when channel is not in use")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSetKeepTopic : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -70,7 +70,7 @@ class CommandCSSetKeepTopic : public Command class CommandCSSASetKeepTopic : public CommandCSSetKeepTopic { public: - CommandCSSASetKeepTopic(Module *creator) : CommandCSSetKeepTopic(creator, "chanserv/saset/keeptopic", "chanserv/saset/keeptopic") + CommandCSSASetKeepTopic(Module *creator) : CommandCSSetKeepTopic(creator, "chanserv/saset/keeptopic") { } }; diff --git a/modules/core/cs_set_opnotice.cpp b/modules/core/cs_set_opnotice.cpp index cfcaf358c..018b89437 100644 --- a/modules/core/cs_set_opnotice.cpp +++ b/modules/core/cs_set_opnotice.cpp @@ -16,7 +16,7 @@ class CommandCSSetOpNotice : public Command { public: - CommandCSSetOpNotice(Module *creator, const Anope::string &cname = "chanserv/set/notice", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetOpNotice(Module *creator, const Anope::string &cname = "chanserv/set/notice") : Command(creator, cname, 2, 2) { this->SetDesc(_("Send a notice when OP/DEOP commands are used")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSetOpNotice : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -69,7 +69,7 @@ class CommandCSSetOpNotice : public Command class CommandCSSASetOpNotice : public CommandCSSetOpNotice { public: - CommandCSSASetOpNotice(Module *creator) : CommandCSSetOpNotice(creator, "chanserv/saset/opnotice", "chanserv/saset/opnotice") + CommandCSSASetOpNotice(Module *creator) : CommandCSSetOpNotice(creator, "chanserv/saset/opnotice") { } }; diff --git a/modules/core/cs_set_peace.cpp b/modules/core/cs_set_peace.cpp index cb208e540..3a045fc6d 100644 --- a/modules/core/cs_set_peace.cpp +++ b/modules/core/cs_set_peace.cpp @@ -16,7 +16,7 @@ class CommandCSSetPeace : public Command { public: - CommandCSSetPeace(Module *creator, const Anope::string &cname = "chanserv/set/peace", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetPeace(Module *creator, const Anope::string &cname = "chanserv/set/peace") : Command(creator, cname, 2, 2) { this->SetDesc(_("Regulate the use of critical commands")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSetPeace : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -69,7 +69,7 @@ class CommandCSSetPeace : public Command class CommandCSSASetPeace : public CommandCSSetPeace { public: - CommandCSSASetPeace(Module *creator) : CommandCSSetPeace(creator, "chanserv/saset/peace", "chanserv/saset/peace") + CommandCSSASetPeace(Module *creator) : CommandCSSetPeace(creator, "chanserv/saset/peace") { } }; diff --git a/modules/core/cs_set_persist.cpp b/modules/core/cs_set_persist.cpp index 2402a3370..3cc9564c4 100644 --- a/modules/core/cs_set_persist.cpp +++ b/modules/core/cs_set_persist.cpp @@ -16,7 +16,7 @@ class CommandCSSetPersist : public Command { public: - CommandCSSetPersist(Module *creator, const Anope::string &cname = "chanserv/set/persist", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetPersist(Module *creator, const Anope::string &cname = "chanserv/set/persist") : Command(creator, cname, 2, 2) { this->SetDesc(_("Set the channel as permanent")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSetPersist : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -156,7 +156,7 @@ class CommandCSSetPersist : public Command class CommandCSSASetPersist : public CommandCSSetPersist { public: - CommandCSSASetPersist(Module *creator) : CommandCSSetPersist(creator, "chanserv/saset/persist", "chanserv/saset/persist") + CommandCSSASetPersist(Module *creator) : CommandCSSetPersist(creator, "chanserv/saset/persist") { } }; diff --git a/modules/core/cs_set_private.cpp b/modules/core/cs_set_private.cpp index 85880d5da..108b11569 100644 --- a/modules/core/cs_set_private.cpp +++ b/modules/core/cs_set_private.cpp @@ -16,7 +16,7 @@ class CommandCSSetPrivate : public Command { public: - CommandCSSetPrivate(Module *creator, const Anope::string &cname = "chanserv/set/private", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetPrivate(Module *creator, const Anope::string &cname = "chanserv/set/private") : Command(creator, cname, 2, 2) { this->SetDesc(_("Hide channel from LIST command")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSetPrivate : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -69,7 +69,7 @@ class CommandCSSetPrivate : public Command class CommandCSSASetPrivate : public CommandCSSetPrivate { public: - CommandCSSASetPrivate(Module *creator) : CommandCSSetPrivate(creator, "chanserv/saset/private", "chanserv/saset/private") + CommandCSSASetPrivate(Module *creator) : CommandCSSetPrivate(creator, "chanserv/saset/private") { } }; diff --git a/modules/core/cs_set_restricted.cpp b/modules/core/cs_set_restricted.cpp index 9796c97da..5d675d2e7 100644 --- a/modules/core/cs_set_restricted.cpp +++ b/modules/core/cs_set_restricted.cpp @@ -15,7 +15,7 @@ class CommandCSSetRestricted : public Command { public: - CommandCSSetRestricted(Module *creator, const Anope::string &cname = "chanserv/set/restricted", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetRestricted(Module *creator, const Anope::string &cname = "chanserv/set/restricted") : Command(creator, cname, 2, 2) { this->SetDesc(_("Restrict access to the channel")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -31,7 +31,7 @@ class CommandCSSetRestricted : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -67,7 +67,7 @@ class CommandCSSetRestricted : public Command class CommandCSSASetRestricted : public CommandCSSetRestricted { public: - CommandCSSASetRestricted(Module *creator) : CommandCSSetRestricted(creator, "chanserv/saset/restricted", "chanserv/saset/restricted") + CommandCSSASetRestricted(Module *creator) : CommandCSSetRestricted(creator, "chanserv/saset/restricted") { } }; diff --git a/modules/core/cs_set_secure.cpp b/modules/core/cs_set_secure.cpp index 2042ed7b9..26e8c5768 100644 --- a/modules/core/cs_set_secure.cpp +++ b/modules/core/cs_set_secure.cpp @@ -16,7 +16,7 @@ class CommandCSSetSecure : public Command { public: - CommandCSSetSecure(Module *creator, const Anope::string &cname = "chanserv/set/secure", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetSecure(Module *creator, const Anope::string &cname = "chanserv/set/secure") : Command(creator, cname, 2, 2) { this->SetDesc(_("Activate security features")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSetSecure : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -70,7 +70,7 @@ class CommandCSSetSecure : public Command class CommandCSSASetSecure : public CommandCSSetSecure { public: - CommandCSSASetSecure(Module *creator) : CommandCSSetSecure(creator, "chanserv/saset/secure", "chanserv/saset/secure") + CommandCSSASetSecure(Module *creator) : CommandCSSetSecure(creator, "chanserv/saset/secure") { } }; diff --git a/modules/core/cs_set_securefounder.cpp b/modules/core/cs_set_securefounder.cpp index 6e11bbce4..7afc2e32d 100644 --- a/modules/core/cs_set_securefounder.cpp +++ b/modules/core/cs_set_securefounder.cpp @@ -16,7 +16,7 @@ class CommandCSSetSecureFounder : public Command { public: - CommandCSSetSecureFounder(Module *creator, const Anope::string &cname = "chanserv/set/securefounder", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetSecureFounder(Module *creator, const Anope::string &cname = "chanserv/set/securefounder") : Command(creator, cname, 2, 2) { this->SetDesc(_("Stricter control of channel founder status")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -33,7 +33,7 @@ class CommandCSSetSecureFounder : public Command } - if (this->permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->HasPriv(u, CA_FOUNDER)) + if (source.permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->HasPriv(u, CA_FOUNDER)) { source.Reply(ACCESS_DENIED); return; @@ -71,7 +71,7 @@ class CommandCSSetSecureFounder : public Command class CommandCSSASetSecureFounder : public CommandCSSetSecureFounder { public: - CommandCSSASetSecureFounder(Module *creator) : CommandCSSetSecureFounder(creator, "chanserv/saset/securefounder", "chanserv/saset/securefounder") + CommandCSSASetSecureFounder(Module *creator) : CommandCSSetSecureFounder(creator, "chanserv/saset/securefounder") { } }; diff --git a/modules/core/cs_set_secureops.cpp b/modules/core/cs_set_secureops.cpp index ed15f7cb5..4c3c54b05 100644 --- a/modules/core/cs_set_secureops.cpp +++ b/modules/core/cs_set_secureops.cpp @@ -16,7 +16,7 @@ class CommandCSSetSecureOps : public Command { public: - CommandCSSetSecureOps(Module *creator, const Anope::string &cname = "chanserv/set/secureops", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetSecureOps(Module *creator, const Anope::string &cname = "chanserv/set/secureops") : Command(creator, cname, 2, 2) { this->SetDesc(_("Stricter control of chanop status")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSetSecureOps : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -68,7 +68,7 @@ class CommandCSSetSecureOps : public Command class CommandCSSASetSecureOps : public CommandCSSetSecureOps { public: - CommandCSSASetSecureOps(Module *creator) : CommandCSSetSecureOps(creator, "chanserv/saset/secureops", "chanserv/saset/secureops") + CommandCSSASetSecureOps(Module *creator) : CommandCSSetSecureOps(creator, "chanserv/saset/secureops") { } }; diff --git a/modules/core/cs_set_signkick.cpp b/modules/core/cs_set_signkick.cpp index 38894b62b..0d421576d 100644 --- a/modules/core/cs_set_signkick.cpp +++ b/modules/core/cs_set_signkick.cpp @@ -16,7 +16,7 @@ class CommandCSSetSignKick : public Command { public: - CommandCSSetSignKick(Module *creator, const Anope::string &cname = "chanserv/set/signkick", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetSignKick(Module *creator, const Anope::string &cname = "chanserv/set/signkick") : Command(creator, cname, 2, 2) { this->SetDesc(_("Sign kicks that are done with KICK command")); this->SetSyntax(_("\037channel\037 SIGNKICK {ON | LEVEL | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSetSignKick : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -80,7 +80,7 @@ class CommandCSSetSignKick : public Command class CommandCSSASetSignKick : public CommandCSSetSignKick { public: - CommandCSSASetSignKick(Module *creator) : CommandCSSetSignKick(creator, "chanserv/saset/signkick", "chanserv/saset/signkick") + CommandCSSASetSignKick(Module *creator) : CommandCSSetSignKick(creator, "chanserv/saset/signkick") { } }; diff --git a/modules/core/cs_set_successor.cpp b/modules/core/cs_set_successor.cpp index a1c756b5d..f7ed8dba9 100644 --- a/modules/core/cs_set_successor.cpp +++ b/modules/core/cs_set_successor.cpp @@ -16,7 +16,7 @@ class CommandCSSetSuccessor : public Command { public: - CommandCSSetSuccessor(Module *creator, const Anope::string &cname = "chanserv/set/successor", const Anope::string &cpermission = "") : Command(creator, cname, 1, 2, cpermission) + CommandCSSetSuccessor(Module *creator, const Anope::string &cname = "chanserv/set/successor") : Command(creator, cname, 1, 2) { this->SetDesc(_("Set the successor for a channel")); this->SetSyntax(_("\037channel\037 \037nick\037")); @@ -32,13 +32,13 @@ class CommandCSSetSuccessor : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; } - if (this->permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->HasPriv(u, CA_FOUNDER)) + if (source.permission.empty() && ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->HasPriv(u, CA_FOUNDER)) { source.Reply(ACCESS_DENIED); return; @@ -65,7 +65,7 @@ class CommandCSSetSuccessor : public Command else nc = NULL; - Log(!this->permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the successor from " << (ci->successor ? ci->successor->display : "none") << " to " << (nc ? nc->display : "none"); + Log(!source.permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the successor from " << (ci->successor ? ci->successor->display : "none") << " to " << (nc ? nc->display : "none"); ci->successor = nc; @@ -95,7 +95,7 @@ class CommandCSSetSuccessor : public Command class CommandCSSASetSuccessor : public CommandCSSetSuccessor { public: - CommandCSSASetSuccessor(Module *creator) : CommandCSSetSuccessor(creator, "chanserv/saset/successor", "chanserv/saset/successor") + CommandCSSASetSuccessor(Module *creator) : CommandCSSetSuccessor(creator, "chanserv/saset/successor") { } }; diff --git a/modules/core/cs_set_topiclock.cpp b/modules/core/cs_set_topiclock.cpp index 3dea981f6..e670385ba 100644 --- a/modules/core/cs_set_topiclock.cpp +++ b/modules/core/cs_set_topiclock.cpp @@ -16,7 +16,7 @@ class CommandCSSetTopicLock : public Command { public: - CommandCSSetTopicLock(Module *creator, const Anope::string &cname = "chanserv/set/topiclock", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) + CommandCSSetTopicLock(Module *creator, const Anope::string &cname = "chanserv/set/topiclock") : Command(creator, cname, 2, 2) { this->SetDesc(_("Topic can only be changed with TOPIC")); this->SetSyntax(_("\037channel\037 {ON | OFF}")); @@ -32,7 +32,7 @@ class CommandCSSetTopicLock : public Command return; } - if (!this->permission.empty() && !ci->HasPriv(u, CA_SET)) + if (source.permission.empty() && !ci->HasPriv(u, CA_SET)) { source.Reply(ACCESS_DENIED); return; @@ -68,7 +68,7 @@ class CommandCSSetTopicLock : public Command class CommandCSSASetTopicLock : public CommandCSSetTopicLock { public: - CommandCSSASetTopicLock(Module *creator) : CommandCSSetTopicLock(creator, "chanserv/saset/topiclock", "chanserv/saset/topiclock") + CommandCSSASetTopicLock(Module *creator) : CommandCSSetTopicLock(creator, "chanserv/saset/topiclock") { } }; diff --git a/modules/core/cs_suspend.cpp b/modules/core/cs_suspend.cpp index 0e0a72bcf..d59ffb44b 100644 --- a/modules/core/cs_suspend.cpp +++ b/modules/core/cs_suspend.cpp @@ -16,7 +16,7 @@ class CommandCSSuspend : public Command { public: - CommandCSSuspend(Module *creator) : Command(creator, "chanserv/suspend", 1, 2, "chanserv/suspend") + CommandCSSuspend(Module *creator) : Command(creator, "chanserv/suspend", 1, 2) { this->SetDesc(_("Prevent a channel from being used preserving channel data and settings")); this->SetSyntax(_("\037channel\037 [\037reason\037]")); @@ -86,7 +86,7 @@ class CommandCSSuspend : public Command class CommandCSUnSuspend : public Command { public: - CommandCSUnSuspend(Module *creator) : Command(creator, "chanserv/unsuspend", 1, 1, "chanserv/suspend") + CommandCSUnSuspend(Module *creator) : Command(creator, "chanserv/unsuspend", 1, 1) { this->SetDesc(_("Releases a suspended channel")); this->SetSyntax(_("\037channel\037")); diff --git a/modules/core/db_mysql.cpp b/modules/core/db_mysql.cpp index 3f18230fe..4e6a7de4f 100644 --- a/modules/core/db_mysql.cpp +++ b/modules/core/db_mysql.cpp @@ -52,7 +52,7 @@ static void WriteBotMetadata(const Anope::string &key, const Anope::string &data class CommandSQLSync : public Command { public: - CommandSQLSync(Module *creator) : Command(creator, "SQLSYNC", 0, 0, "operserv/sqlsync") + CommandSQLSync(Module *creator) : Command(creator, "SQLSYNC", 0, 0) { this->SetDesc(_("Import your databases to SQL")); this->SetSyntax(""); diff --git a/modules/core/gl_global.cpp b/modules/core/gl_global.cpp index 390d912ef..80c42e017 100644 --- a/modules/core/gl_global.cpp +++ b/modules/core/gl_global.cpp @@ -17,7 +17,7 @@ class CommandGLGlobal : public Command { public: - CommandGLGlobal(Module *creator) : Command(creator, "global/global", 1, 1, "global/global") + CommandGLGlobal(Module *creator) : Command(creator, "global/global", 1, 1) { this->SetDesc(_("Send a message to all users")); this->SetSyntax(_("\037message\037")); diff --git a/modules/core/help.cpp b/modules/core/help.cpp index 8362b48d9..2a4f25b6c 100644 --- a/modules/core/help.cpp +++ b/modules/core/help.cpp @@ -32,19 +32,22 @@ class CommandHelp : public Command if (params.empty()) { - for (command_map::iterator it = bi->commands.begin(), it_end = bi->commands.end(); it != it_end; ++it) + for (BotInfo::command_map::iterator it = bi->commands.begin(), it_end = bi->commands.end(); it != it_end; ++it) { + const Anope::string &c_name = it->first; + CommandInfo &info = it->second; + // Smaller command exists - Anope::string cmd = myStrGetToken(it->first, ' ', 0); + Anope::string cmd = myStrGetToken(c_name, ' ', 0); if (cmd != it->first && bi->commands.count(cmd)) continue; - service_reference c(it->second); + service_reference c(info.name); if (!c) continue; - if (!Config->HidePrivilegedCommands || c->permission.empty() || u->HasCommand(c->permission)) + if (!Config->HidePrivilegedCommands || info.permission.empty() || u->HasCommand(info.permission)) { - source.command = it->first; + source.command = c_name; c->OnServHelp(source); } } @@ -59,15 +62,17 @@ class CommandHelp : public Command full_command += " " + params[i]; full_command.erase(full_command.begin()); - std::map::iterator it = bi->commands.find(full_command); + BotInfo::command_map::iterator it = bi->commands.find(full_command); if (it == bi->commands.end()) continue; - service_reference c(it->second); + CommandInfo &info = it->second; + + service_reference c(info.name); if (!c) continue; - if (Config->HidePrivilegedCommands && !c->permission.empty() && !u->HasCommand(c->permission)) + if (Config->HidePrivilegedCommands && !info.permission.empty() && !u->HasCommand(info.permission)) continue; const Anope::string &subcommand = params.size() > max ? params[max] : ""; @@ -76,19 +81,24 @@ class CommandHelp : public Command continue; helped = true; - source.Reply(" "); /* Inform the user what permission is required to use the command */ - if (!c->permission.empty()) - source.Reply(_("Access to this command requires the permission \002%s\002 to be present in your opertype."), c->permission.c_str()); + if (!info.permission.empty()) + { + source.Reply(" "); + source.Reply(_("Access to this command requires the permission \002%s\002 to be present in your opertype."), info.permission.c_str