diff options
author | Adam <Adam@anope.org> | 2010-08-03 01:49:15 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-08-03 01:49:15 -0400 |
commit | 59ee16c7cb14d1ac80b9ed9b89d868af45de5ee5 (patch) | |
tree | 68e41ef54f6a77f8e8b75e80ef5eeda9a2ecdf04 /modules/core/ns_set_autoop.cpp | |
parent | 7b27a4e49192645b67eddba829a588e9e6d978ee (diff) |
Made ns set/saset work like cs set/saset, cleans up a lot of code
Diffstat (limited to 'modules/core/ns_set_autoop.cpp')
-rw-r--r-- | modules/core/ns_set_autoop.cpp | 48 |
1 files changed, 15 insertions, 33 deletions
diff --git a/modules/core/ns_set_autoop.cpp b/modules/core/ns_set_autoop.cpp index 1e6e0d812..8e0c0a8ad 100644 --- a/modules/core/ns_set_autoop.cpp +++ b/modules/core/ns_set_autoop.cpp @@ -16,21 +16,27 @@ class CommandNSSetAutoOp : public Command { public: - CommandNSSetAutoOp() : Command("AUTOOP", 1) + CommandNSSetAutoOp(const Anope::string &spermission = "") : Command("AUTOOP", 1, 2, spermission) { } CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) { - if (params[0].equals_ci("ON")) + NickCore *nc = findcore(params[0]); + if (!nc) + throw CoreException("NULL nc in CommandNSSetAutoOp"); + + Anope::string param = params.size() > 1 ? params[1] : ""; + + if (param.equals_ci("ON")) { - u->Account()->SetFlag(NI_AUTOOP); - notice_lang(Config.s_NickServ, u, NICK_SET_AUTOOP_ON); + nc->SetFlag(NI_AUTOOP); + notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_ON, nc->display.c_str()); } - else if (params[0].equals_ci("OFF")) + else if (param.equals_ci("OFF")) { - u->Account()->UnsetFlag(NI_AUTOOP); - notice_lang(Config.s_NickServ, u, NICK_SET_AUTOOP_OFF); + nc->UnsetFlag(NI_AUTOOP); + notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_OFF, nc->display.c_str()); } else this->OnSyntaxError(u, "AUTOOP"); @@ -55,35 +61,11 @@ class CommandNSSetAutoOp : public Command } }; -class CommandNSSASetAutoOp : public Command +class CommandNSSASetAutoOp : public CommandNSSetAutoOp { public: - CommandNSSASetAutoOp() : Command("AUTOOP", 2, 2, "nickserv/saset/autoop") - { - } - - CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) + CommandNSSASetAutoOp() : CommandNSSetAutoOp("nickserv/saset/autoop") { - NickCore *nc = findcore(params[0]); - if (!nc) - throw CoreException("NULL nc in CommandNSSASetAutoOp"); - - Anope::string param = params[1]; - - if (param.equals_ci("ON")) - { - nc->SetFlag(NI_AUTOOP); - notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_ON, nc->display.c_str()); - } - else if (param.equals_ci("OFF")) - { - nc->UnsetFlag(NI_AUTOOP); - notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_OFF, nc->display.c_str()); - } - else - this->OnSyntaxError(u, "AUTOOP"); - - return MOD_CONT; } bool Help(User *u, const Anope::string &) |