diff options
author | Adam <Adam@anope.org> | 2011-07-14 02:31:12 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-07-14 02:31:12 -0400 |
commit | f858164deed48f2dcacd5ffc06a55398a54da7e8 (patch) | |
tree | 89c3cf36bd8e94942370135218d67d6d17ee222e /modules/core/ns_getpass.cpp | |
parent | 924f6849fee4598a1a3a7f1a98d96b79e5ffd3b4 (diff) |
Rewrote how commands are handled within Anope.
This allows naming commands and having spaces within command names.
Diffstat (limited to 'modules/core/ns_getpass.cpp')
-rw-r--r-- | modules/core/ns_getpass.cpp | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/modules/core/ns_getpass.cpp b/modules/core/ns_getpass.cpp index 3d7ceb3ae..ab4bcd4e2 100644 --- a/modules/core/ns_getpass.cpp +++ b/modules/core/ns_getpass.cpp @@ -12,17 +12,17 @@ /*************************************************************************/ #include "module.h" -#include "nickserv.h" class CommandNSGetPass : public Command { public: - CommandNSGetPass() : Command("GETPASS", 1, 1, "nickserv/getpass") + CommandNSGetPass(Module *creator) : Command(creator, "nickserv/getpass", 1, 1, "nickserv/getpass") { this->SetDesc(_("Retrieve the password for a nickname")); + this->SetSyntax(_("\037nickname\037")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.u; const Anope::string &nick = params[0]; @@ -30,9 +30,9 @@ class CommandNSGetPass : public Command NickAlias *na; if (!(na = findnick(nick))) - source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); + source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (Config->NSSecureAdmins && na->nc->IsServicesOper()) - source.Reply(_(ACCESS_DENIED)); + source.Reply(ACCESS_DENIED); else { if (enc_decrypt(na->nc->pass, tmp_pass) == 1) @@ -43,24 +43,19 @@ class CommandNSGetPass : public Command else source.Reply(_("GETPASS command unavailable because encryption is in use.")); } - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) { - source.Reply(_("Syntax: \002GETPASS \037nickname\037\002\n" - " \n" - "Returns the password for the given nickname. \002Note\002 that\n" + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Returns the password for the given nickname. \002Note\002 that\n" "whenever this command is used, a message including the\n" "person who issued the command and the nickname it was used\n" "on will be logged and sent out as a WALLOPS/GLOBOPS.")); return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - SyntaxError(source, "GETPASS", _("GETPASS \037nickname\037")); - } }; class NSGetPass : public Module @@ -68,18 +63,16 @@ class NSGetPass : public Module CommandNSGetPass commandnsgetpass; public: - NSGetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) + NSGetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), + commandnsgetpass(this) { this->SetAuthor("Anope"); - if (!nickserv) - throw ModuleException("NickServ is not loaded!"); - Anope::string tmp_pass = "plain:tmp"; if (enc_decrypt(tmp_pass, tmp_pass) == -1) throw ModuleException("Incompatible with the encryption module being used"); - this->AddCommand(nickserv->Bot(), &commandnsgetpass); + ModuleManager::RegisterService(&commandnsgetpass); } }; |