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/cs_set_secure.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/cs_set_secure.cpp')
-rw-r--r-- | modules/core/cs_set_secure.cpp | 76 |
1 files changed, 29 insertions, 47 deletions
diff --git a/modules/core/cs_set_secure.cpp b/modules/core/cs_set_secure.cpp index 39d50fad2..73013be32 100644 --- a/modules/core/cs_set_secure.cpp +++ b/modules/core/cs_set_secure.cpp @@ -12,21 +12,31 @@ /*************************************************************************/ #include "module.h" -#include "chanserv.h" class CommandCSSetSecure : public Command { public: - CommandCSSetSecure(const Anope::string &cpermission = "") : Command("SECURE", 2, 2, cpermission) + CommandCSSetSecure(Module *creator, const Anope::string &cname = "chanserv/set/secure", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission) { - this->SetDesc(Anope::printf(_("Activate %s's security features"), Config->s_ChanServ.c_str())); + this->SetDesc(_("Activate security features")); + this->SetSyntax(_("\037channel\037 SECURE {ON | OFF}")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { - ChannelInfo *ci = source.ci; - if (!ci) - throw CoreException("NULL ci in CommandCSSetSecure"); + User *u = source.u; + ChannelInfo *ci = cs_findchan(params[0]); + if (ci == NULL) + { + source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); + return; + } + + if (!this->permission.empty() && !check_access(u, ci, CA_SET)) + { + source.Reply(ACCESS_DENIED); + return; + } if (params[1].equals_ci("ON")) { @@ -41,38 +51,28 @@ class CommandCSSetSecure : public Command else this->OnSyntaxError(source, "SECURE"); - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &) { - source.Reply(_("Syntax: \002%s \037channel\037 SECURE {ON | OFF}\002\n" - " \n" - "Enables or disables %s's security features for a\n" - "channel. When \002SECURE\002 is set, only users who have\n" - "registered their nicknames with %s and IDENTIFY'd\n" + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Enables or disables security features for a\n" + "channel. When \002%s\002 is set, only users who have\n" + "registered their nicknames and IDENTIFY'd\n" "with their password will be given access to the channel\n" - "as controlled by the access list."), this->name.c_str(), Config->s_NickServ.c_str(), Config->s_NickServ.c_str()); + "as controlled by the access list."), this->name.c_str()); return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &) - { - SyntaxError(source, "SET SECURE", _("SET \037channel\037 SECURE {ON | OFF}")); - } }; class CommandCSSASetSecure : public CommandCSSetSecure { public: - CommandCSSASetSecure() : CommandCSSetSecure("chanserv/saset/secure") + CommandCSSASetSecure(Module *creator) : CommandCSSetSecure(creator, "chanserv/saset/secure", "chanserv/saset/secure") { } - - void OnSyntaxError(CommandSource &source, const Anope::string &) - { - SyntaxError(source, "SASET SECURE", _("SASET \002channel\002 SECURE {ON | OFF}")); - } }; class CSSetSecure : public Module @@ -81,31 +81,13 @@ class CSSetSecure : public Module CommandCSSASetSecure commandcssasetsecure; public: - CSSetSecure(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE) + CSSetSecure(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), + commandcssetsecure(this), commandcssasetsecure(this) { this->SetAuthor("Anope"); - if (!chanserv) - throw ModuleException("ChanServ is not loaded!"); - - Command *c = FindCommand(chanserv->Bot(), "SET"); - if (c) - c->AddSubcommand(this, &commandcssetsecure); - - c = FindCommand(chanserv->Bot(), "SASET"); - if (c) - c->AddSubcommand(this, &commandcssasetsecure); - } - - ~CSSetSecure() - { - Command *c = FindCommand(chanserv->Bot(), "SET"); - if (c) - c->DelSubcommand(&commandcssetsecure); - - c = FindCommand(chanserv->Bot(), "SASET"); - if (c) - c->DelSubcommand(&commandcssasetsecure); + ModuleManager::RegisterService(&commandcssetsecure); + ModuleManager::RegisterService(&commandcssasetsecure); } }; |