mirror of
https://github.com/anope/anope.git
synced 2026-07-07 10:43:14 +02:00
Rewrote how commands are handled within Anope.
This allows naming commands and having spaces within command names.
This commit is contained in:
@@ -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> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user