1
0
mirror of https://github.com/anope/anope.git synced 2026-07-04 05:33:12 +02:00

Rewrote how commands are handled within Anope.

This allows naming commands and having spaces within command names.
This commit is contained in:
Adam
2011-07-14 02:31:12 -04:00
parent 924f6849fe
commit f858164dee
227 changed files with 8808 additions and 12352 deletions
+30 -50
View File
@@ -12,25 +12,26 @@
/*************************************************************************/
#include "module.h"
#include "nickserv.h"
class CommandNSSetSecure : public Command
{
public:
CommandNSSetSecure(const Anope::string &cpermission = "") : Command("SECURE", 2, 2, cpermission)
CommandNSSetSecure(Module *creator, const Anope::string &sname = "nickserv/set/secure", size_t min = 1, const Anope::string &cpermission = "") : Command(creator, sname, min, min + 1, cpermission)
{
this->SetDesc(_("Turn nickname security on or off"));
this->SetSyntax(_("{ON | OFF}"));
}
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
void Run(CommandSource &source, const Anope::string &user, const Anope::string &param)
{
NickAlias *na = findnick(params[0]);
NickAlias *na = findnick(user);
if (!na)
throw CoreException("NULL na in CommandNSSetSecure");
{
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
return;
}
NickCore *nc = na->nc;
Anope::string param = params[1];
if (param.equals_ci("ON"))
{
nc->SetFlag(NI_SECURE);
@@ -43,55 +44,55 @@ class CommandNSSetSecure : public Command
}
else
this->OnSyntaxError(source, "SECURE");
}
return MOD_CONT;
void Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
this->Run(source, source.u->Account()->display, params[0]);
}
bool OnHelp(CommandSource &source, const Anope::string &)
{
source.Reply(_("Syntax: \002SET SECURE {ON | OFF}\002\n"
" \n"
"Turns %s's security features on or off for your\n"
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Turns %s's security features on or off for your\n"
"nick. With \002SECURE\002 set, you must enter your password\n"
"before you will be recognized as the owner of the nick,\n"
"regardless of whether your address is on the access\n"
"list. However, if you are on the access list, %s\n"
"will not auto-kill you regardless of the setting of the\n"
"\002KILL\002 option."), Config->s_NickServ.c_str(), Config->s_NickServ.c_str());
"\002KILL\002 option."), Config->NickServ.c_str(), Config->NickServ.c_str());
return true;
}
void OnSyntaxError(CommandSource &source, const Anope::string &)
{
SyntaxError(source, "SET SECURE", _("SET SECURE {ON | OFF}"));
}
};
class CommandNSSASetSecure : public CommandNSSetSecure
{
public:
CommandNSSASetSecure() : CommandNSSetSecure("nickserv/saset/secure")
CommandNSSASetSecure(Module *creator) : CommandNSSetSecure(creator, "nickserv/saset/secure", 2, "nickserv/saset/secure")
{
this->ClearSyntax();
this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
this->Run(source, params[0], params[1]);
}
bool OnHelp(CommandSource &source, const Anope::string &)
{
source.Reply(_("Syntax: \002SASET \037nickname\037 SECURE {ON | OFF}\002\n"
" \n"
"Turns %s's security features on or off for your\n"
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Turns %s's security features on or off for your\n"
"nick. With \002SECURE\002 set, you must enter your password\n"
"before you will be recognized as the owner of the nick,\n"
"regardless of whether your address is on the access\n"
"list. However, if you are on the access list, %s\n"
"will not auto-kill you regardless of the setting of the\n"
"\002KILL\002 option."), Config->s_NickServ.c_str(), Config->s_NickServ.c_str());
"\002KILL\002 option."), Config->NickServ.c_str(), Config->NickServ.c_str());
return true;
}
void OnSyntaxError(CommandSource &source, const Anope::string &)
{
SyntaxError(source, "SASET SECURE", _("SASET \037nickname\037 SECURE {ON | OFF}"));
}
};
class NSSetSecure : public Module
@@ -100,31 +101,10 @@ class NSSetSecure : public Module
CommandNSSASetSecure commandnssasetsecure;
public:
NSSetSecure(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE)
NSSetSecure(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
commandnssetsecure(this), commandnssasetsecure(this)
{
this->SetAuthor("Anope");
if (!nickserv)
throw ModuleException("NickServ is not loaded!");
Command *c = FindCommand(nickserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandnssetsecure);
c = FindCommand(nickserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandnssasetsecure);
}
~NSSetSecure()
{
Command *c = FindCommand(nickserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandnssetsecure);
c = FindCommand(nickserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandnssasetsecure);
}
};