diff options
Diffstat (limited to 'modules/core/ns_access.cpp')
-rw-r--r-- | modules/core/ns_access.cpp | 73 |
1 files changed, 33 insertions, 40 deletions
diff --git a/modules/core/ns_access.cpp b/modules/core/ns_access.cpp index d25520d43..df9ae6eed 100644 --- a/modules/core/ns_access.cpp +++ b/modules/core/ns_access.cpp @@ -12,12 +12,11 @@ /*************************************************************************/ #include "module.h" -#include "nickserv.h" class CommandNSAccess : public Command { private: - CommandReturn DoServAdminList(CommandSource &source, const std::vector<Anope::string> ¶ms, NickCore *nc) + void DoServAdminList(CommandSource &source, const std::vector<Anope::string> ¶ms, NickCore *nc) { Anope::string mask = params.size() > 2 ? params[2] : ""; unsigned i, end; @@ -25,13 +24,13 @@ class CommandNSAccess : public Command if (nc->access.empty()) { source.Reply(_("Access list for \002%s\002 is empty."), nc->display.c_str()); - return MOD_CONT; + return; } if (nc->HasFlag(NI_SUSPENDED)) { - source.Reply(_(NICK_X_SUSPENDED), nc->display.c_str()); - return MOD_CONT; + source.Reply(NICK_X_SUSPENDED, nc->display.c_str()); + return; } source.Reply(_("Access list for \002%s\002:"), params[1].c_str()); @@ -43,57 +42,57 @@ class CommandNSAccess : public Command source.Reply(" %s", access.c_str()); } - return MOD_CONT; + return; } - CommandReturn DoAdd(CommandSource &source, NickCore *nc, const Anope::string &mask) + void DoAdd(CommandSource &source, NickCore *nc, const Anope::string &mask) { if (mask.empty()) { this->OnSyntaxError(source, "ADD"); - return MOD_CONT; + return; } if (nc->access.size() >= Config->NSAccessMax) { source.Reply(_("Sorry, you can only have %d access entries for a nickname."), Config->NSAccessMax); - return MOD_CONT; + return; } if (nc->FindAccess(mask)) { source.Reply(_("Mask \002%s\002 already present on your access list."), mask.c_str()); - return MOD_CONT; + return; } nc->AddAccess(mask); source.Reply(_("\002%s\002 added to your access list."), mask.c_str()); - return MOD_CONT; + return; } - CommandReturn DoDel(CommandSource &source, NickCore *nc, const Anope::string &mask) + void DoDel(CommandSource &source, NickCore *nc, const Anope::string &mask) { if (mask.empty()) { this->OnSyntaxError(source, "DEL"); - return MOD_CONT; + return; } if (!nc->FindAccess(mask)) { source.Reply(_("\002%s\002 not found on your access list."), mask.c_str()); - return MOD_CONT; + return; } source.Reply(_("\002%s\002 deleted from your access list."), mask.c_str()); nc->EraseAccess(mask); - return MOD_CONT; + return; } - CommandReturn DoList(CommandSource &source, NickCore *nc, const Anope::string &mask) + void DoList(CommandSource &source, NickCore *nc, const Anope::string &mask) { User *u = source.u; unsigned i, end; @@ -101,7 +100,7 @@ class CommandNSAccess : public Command if (nc->access.empty()) { source.Reply(_("Your access list is empty."), u->nick.c_str()); - return MOD_CONT; + return; } source.Reply(_("Access list:")); @@ -113,15 +112,18 @@ class CommandNSAccess : public Command source.Reply(" %s", access.c_str()); } - return MOD_CONT; + return; } public: - CommandNSAccess() : Command("ACCESS", 1, 3) + CommandNSAccess(Module *creator) : Command(creator, "nickserv/access", 1, 3) { this->SetDesc(_("Modify the list of authorized addresses")); + this->SetSyntax(_("ADD \037mask\037")); + this->SetSyntax(_("DEL \037mask\037")); + this->SetSyntax(_("LIST")); } - 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 &cmd = params[0]; @@ -133,11 +135,11 @@ class CommandNSAccess : public Command if (!mask.empty() && mask.find('@') == Anope::string::npos) { - source.Reply(_(BAD_USERHOST_MASK)); - source.Reply(_(MORE_INFO), Config->UseStrictPrivMsgString.c_str(), Config->s_NickServ.c_str(), "ACCESS"); + source.Reply(BAD_USERHOST_MASK); + source.Reply(MORE_INFO, Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), this->name.c_str()); } else if (u->Account()->HasFlag(NI_SUSPENDED)) - source.Reply(_(NICK_X_SUSPENDED), u->Account()->display.c_str()); + source.Reply(NICK_X_SUSPENDED, u->Account()->display.c_str()); else if (cmd.equals_ci("ADD")) return this->DoAdd(source, u->Account(), mask); else if (cmd.equals_ci("DEL")) @@ -147,16 +149,14 @@ class CommandNSAccess : public Command else this->OnSyntaxError(source, ""); - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) { - source.Reply(_("Syntax: \002ACCESS ADD \037mask\037\002\n" - " \002ACCESS DEL \037mask\037\002\n" - " \002ACCESS LIST\002\n" - " \n" - "Modifies or displays the access list for your nick. This\n" + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Modifies or displays the access list for your nick. This\n" "is the list of addresses which will be automatically\n" "recognized by %s as allowed to use the nick. If\n" "you want to use the nick from a different address, you\n" @@ -173,14 +173,9 @@ class CommandNSAccess : public Command " Reverses the previous command.\n" " \n" " \002ACCESS LIST\002\n" - " Displays the current access list."), Config->s_NickServ.c_str(), Config->s_NickServ.c_str()); + " Displays the current access list."), Config->NickServ.c_str(), Config->NickServ.c_str()); return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - SyntaxError(source, "ACCESS", _("ACCESS {ADD | DEL | LIST} [\037mask\037]")); - } }; class NSAccess : public Module @@ -188,14 +183,12 @@ class NSAccess : public Module CommandNSAccess commandnsaccess; public: - NSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) + NSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), + commandnsaccess(this) { this->SetAuthor("Anope"); - if (!nickserv) - throw ModuleException("NickServ is not loaded!"); - - this->AddCommand(nickserv->Bot(), &commandnsaccess); + ModuleManager::RegisterService(&commandnsaccess); } }; |