From f858164deed48f2dcacd5ffc06a55398a54da7e8 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 14 Jul 2011 02:31:12 -0400 Subject: Rewrote how commands are handled within Anope. This allows naming commands and having spaces within command names. --- modules/core/ns_saset_noexpire.cpp | 43 +++++++++++++------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) (limited to 'modules/core/ns_saset_noexpire.cpp') diff --git a/modules/core/ns_saset_noexpire.cpp b/modules/core/ns_saset_noexpire.cpp index 0dbee1e29..26da7786f 100644 --- a/modules/core/ns_saset_noexpire.cpp +++ b/modules/core/ns_saset_noexpire.cpp @@ -12,21 +12,24 @@ /*************************************************************************/ #include "module.h" -#include "nickserv.h" class CommandNSSASetNoexpire : public Command { public: - CommandNSSASetNoexpire() : Command("NOEXPIRE", 1, 2, "nickserv/saset/noexpire") + CommandNSSASetNoexpire(Module *creator) : Command(creator, "nickserv/saset/noexpire", 1, 2, "nickserv/saset/noexpire") { this->SetDesc(_("Prevent the nickname from expiring")); + this->SetSyntax(_("\037nickname\037 {ON | OFF}")); } - CommandReturn Execute(CommandSource &source, const std::vector ¶ms) + void Execute(CommandSource &source, const std::vector ¶ms) { NickAlias *na = findnick(params[0]); - if (!na) - throw CoreException("NULL na in CommandNSSASsetNoexpire"); + if (na == NULL) + { + source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str()); + return; + } Anope::string param = params.size() > 1 ? params[1] : ""; @@ -43,22 +46,17 @@ class CommandNSSASetNoexpire : public Command else this->OnSyntaxError(source, "NOEXPIRE"); - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &) { - source.Reply(_("Syntax: \002SASET \037nickname\037 NOEXPIRE {ON | OFF}\002\n" - " \n" - "Sets whether the given nickname will expire. Setting this\n" + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Sets whether the given nickname will expire. Setting this\n" "to \002ON\002 prevents the nickname from expiring.")); return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &) - { - SyntaxError(source, "SASET NOEXPIRE", _("SASET \037nickname\037 NOEXPIRE {ON | OFF}")); - } }; class NSSASetNoexpire : public Module @@ -66,23 +64,12 @@ class NSSASetNoexpire : public Module CommandNSSASetNoexpire commandnssasetnoexpire; public: - NSSASetNoexpire(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) + NSSASetNoexpire(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), + commandnssasetnoexpire(this) { this->SetAuthor("Anope"); - if (!nickserv) - throw ModuleException("NickServ is not loaded!"); - - Command *c = FindCommand(nickserv->Bot(), "SASET"); - if (c) - c->AddSubcommand(this, &commandnssasetnoexpire); - } - - ~NSSASetNoexpire() - { - Command *c = FindCommand(nickserv->Bot(), "SASET"); - if (c) - c->DelSubcommand(&commandnssasetnoexpire); + ModuleManager::RegisterService(&commandnssasetnoexpire); } }; -- cgit