1
0
mirror of https://github.com/anope/anope.git synced 2026-07-07 20:23:13 +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
+17 -24
View File
@@ -12,18 +12,18 @@
/*************************************************************************/
#include "module.h"
#include "nickserv.h"
class CommandNSRelease : public Command
{
public:
CommandNSRelease() : Command("RELEASE", 1, 2)
CommandNSRelease(Module *creator) : Command(creator, "nickserv/release", 1, 2)
{
this->SetFlag(CFLAG_ALLOW_UNREGISTERED);
this->SetDesc(_("Regain custody of your nick after RECOVER"));
this->SetSyntax(_("\037nickname\037 [\037password\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;
const Anope::string &nick = params[0];
@@ -31,17 +31,17 @@ class CommandNSRelease : public Command
NickAlias *na;
if (!(na = findnick(nick)))
source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str());
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
else if (na->nc->HasFlag(NI_SUSPENDED))
source.Reply(_(NICK_X_SUSPENDED), na->nick.c_str());
source.Reply(NICK_X_SUSPENDED, na->nick.c_str());
else if (!na->HasFlag(NS_HELD))
source.Reply(_("Nick \002%s\002 isn't being held."), nick.c_str());
else if (!pass.empty())
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnCheckAuthentication, OnCheckAuthentication(u, this, params, na->nc->display, pass));
FOREACH_RESULT(I_OnCheckAuthentication, OnCheckAuthentication(this, &source, params, na->nc->display, pass));
if (MOD_RESULT == EVENT_STOP)
return MOD_CONT;
return;
if (MOD_RESULT == EVENT_ALLOW)
{
@@ -51,7 +51,7 @@ class CommandNSRelease : public Command
}
else
{
source.Reply(_(ACCESS_DENIED));
source.Reply(ACCESS_DENIED);
Log(LOG_COMMAND, u, this) << "invalid password for " << nick;
bad_password(u);
}
@@ -65,9 +65,9 @@ class CommandNSRelease : public Command
source.Reply(_("Services' hold on your nick has been released."));
}
else
source.Reply(_(ACCESS_DENIED));
source.Reply(ACCESS_DENIED);
}
return MOD_CONT;
return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
@@ -75,9 +75,9 @@ class CommandNSRelease : public Command
/* Convert Config->NSReleaseTimeout seconds to string format */
Anope::string relstr = duration(Config->NSReleaseTimeout);
source.Reply(_("Syntax: \002RELEASE \037nickname\037 [\037password\037]\002\n"
" \n"
"Instructs %s to remove any hold on your nickname\n"
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Instructs %s to remove any hold on your nickname\n"
"caused by automatic kill protection or use of the \002RECOVER\002\n"
"command. This holds lasts for %s;\n"
"This command gets rid of them sooner.\n"
@@ -86,16 +86,11 @@ class CommandNSRelease : public Command
"current address as shown in /WHOIS must be on that nick's\n"
"access list, you must be identified and in the group of\n"
"that nick, or you must supply the correct password for\n"
"the nickname."), Config->s_NickServ.c_str(), relstr.c_str());
"the nickname."), Config->NickServ.c_str(), relstr.c_str());
return true;
}
void OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
{
SyntaxError(source, "RELEASE", _("RELEASE \037nickname\037 [\037password\037]"));
}
};
class NSRelease : public Module
@@ -103,14 +98,12 @@ class NSRelease : public Module
CommandNSRelease commandnsrelease;
public:
NSRelease(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE)
NSRelease(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
commandnsrelease(this)
{
this->SetAuthor("Anope");
if (!nickserv)
throw ModuleException("NickServ is not loaded!");
this->AddCommand(nickserv->Bot(), &commandnsrelease);
ModuleManager::RegisterService(&commandnsrelease);
}
};