summaryrefslogtreecommitdiff
path: root/modules/core/cs_set_founder.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-07-14 02:31:12 -0400
committerAdam <Adam@anope.org>2011-07-14 02:31:12 -0400
commitf858164deed48f2dcacd5ffc06a55398a54da7e8 (patch)
tree89c3cf36bd8e94942370135218d67d6d17ee222e /modules/core/cs_set_founder.cpp
parent924f6849fee4598a1a3a7f1a98d96b79e5ffd3b4 (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_founder.cpp')
-rw-r--r--modules/core/cs_set_founder.cpp79
1 files changed, 29 insertions, 50 deletions
diff --git a/modules/core/cs_set_founder.cpp b/modules/core/cs_set_founder.cpp
index a71794756..97eec8500 100644
--- a/modules/core/cs_set_founder.cpp
+++ b/modules/core/cs_set_founder.cpp
@@ -12,42 +12,51 @@
/*************************************************************************/
#include "module.h"
-#include "chanserv.h"
class CommandCSSetFounder : public Command
{
public:
- CommandCSSetFounder(const Anope::string &cpermission = "") : Command("FOUNDER", 2, 2, cpermission)
+ CommandCSSetFounder(Module *creator, const Anope::string &cname = "chanserv/set/founder", const Anope::string &cpermission = "") : Command(creator, "chanserv/founder", 2, 2, cpermission)
{
this->SetDesc(_("Set the founder of a channel"));
+ this->SetSyntax(_("\037channel\037 FOUNDER \037nick\037"));
}
- CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
+ void Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
User *u = source.u;
- ChannelInfo *ci = source.ci;
- if (!ci)
- throw CoreException("NULL ci in CommandCSSetFounder");
+ 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 (this->permission.empty() && (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !check_access(u, ci, CA_FOUNDER)))
{
- source.Reply(_(ACCESS_DENIED));
- return MOD_CONT;
+ source.Reply(ACCESS_DENIED);
+ return;
}
NickAlias *na = findnick(params[1]);
if (!na)
{
- source.Reply(_(NICK_X_NOT_REGISTERED), params[1].c_str());
- return MOD_CONT;
+ source.Reply(NICK_X_NOT_REGISTERED, params[1].c_str());
+ return;
}
NickCore *nc = na->nc;
if (Config->CSMaxReg && nc->channelcount >= Config->CSMaxReg && !u->HasPriv("chanserv/no-register-limit"))
{
source.Reply(_("\002%s\002 has too many channels registered."), na->nick.c_str());
- return MOD_CONT;
+ return;
}
Log(!this->permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the founder to " << nc->display;
@@ -56,37 +65,25 @@ class CommandCSSetFounder : public Command
source.Reply(_("Founder of %s changed to \002%s\002."), ci->name.c_str(), na->nick.c_str());
- return MOD_CONT;
+ return;
}
bool OnHelp(CommandSource &source, const Anope::string &)
{
- source.Reply(_("Syntax: \002%s \037channel\037 FOUNDER \037nick\037\002\n"
- " \n"
- "Changes the founder of a channel. The new nickname must\n"
+ this->SendSyntax(source);
+ source.Reply(" ");
+ source.Reply(_("Changes the founder of a channel. The new nickname must\n"
"be a registered one."), this->name.c_str());
return true;
}
-
- void OnSyntaxError(CommandSource &source, const Anope::string &)
- {
- // XXX
- SyntaxError(source, "SET", _(CHAN_SET_SYNTAX));
- }
};
class CommandCSSASetFounder : public CommandCSSetFounder
{
public:
- CommandCSSASetFounder() : CommandCSSetFounder("chanserv/saset/founder")
+ CommandCSSASetFounder(Module *creator) : CommandCSSetFounder(creator, "chanserv/saset/founder", "chanserv/saset/founder")
{
}
-
- void OnSyntaxError(CommandSource &source, const Anope::string &)
- {
- // XXX
- SyntaxError(source, "SASET", _(CHAN_SASET_SYNTAX));
- }
};
class CSSetFounder : public Module
@@ -95,31 +92,13 @@ class CSSetFounder : public Module
CommandCSSASetFounder commandcssasetfounder;
public:
- CSSetFounder(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE)
+ CSSetFounder(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
+ commandcssetfounder(this), commandcssasetfounder(this)
{
this->SetAuthor("Anope");
- if (!chanserv)
- throw ModuleException("ChanServ is not loaded!");
-
- Command *c = FindCommand(chanserv->Bot(), "SET");
- if (c)
- c->AddSubcommand(this, &commandcssetfounder);
-
- c = FindCommand(chanserv->Bot(), "SASET");
- if (c)
- c->AddSubcommand(this, &commandcssasetfounder);
- }
-
- ~CSSetFounder()
- {
- Command *c = FindCommand(chanserv->Bot(), "SET");
- if (c)
- c->DelSubcommand(&commandcssetfounder);
-
- c = FindCommand(chanserv->Bot(), "SASET");
- if (c)
- c->DelSubcommand(&commandcssasetfounder);
+ ModuleManager::RegisterService(&commandcssetfounder);
+ ModuleManager::RegisterService(&commandcssasetfounder);
}
};