1
0
mirror of https://github.com/anope/anope.git synced 2026-07-10 19: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:
Adam
2011-07-14 02:31:12 -04:00
parent 924f6849fe
commit f858164dee
227 changed files with 8808 additions and 12352 deletions
+50 -16
View File
@@ -12,17 +12,17 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSDel : public Command
{
public:
CommandHSDel() : Command("DEL", 1, 1, "hostserv/del")
CommandHSDel(Module *creator) : Command(creator, "hostserv/del", 1, 1, "hostserv/del")
{
this->SetDesc(_("Delete the vhost of another user"));
this->SetSyntax(_("\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;
const Anope::string &nick = params[0];
@@ -32,41 +32,75 @@ class CommandHSDel : public Command
Log(LOG_ADMIN, u, this) << "for user " << na->nick;
FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na));
na->hostinfo.RemoveVhost();
source.Reply(_("vhost for \002%s\002 removed."), nick.c_str());
source.Reply(_("Vhost for \002%s\002 removed."), nick.c_str());
}
else
source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str());
return MOD_CONT;
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
source.Reply(_("Syntax: \002DEL\002 \002<nick>\002\n"
"Deletes the vhost assigned to the given nick from the\n"
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Deletes the vhost assigned to the given nick from the\n"
"database."));
return true;
}
};
void OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
class CommandHSDelAll : public Command
{
public:
CommandHSDelAll(Module *creator) : Command(creator, "hostserv/delall", 1, 1, "hostserv/del")
{
SyntaxError(source, "DEL", _("DEL \002<nick>\002."));
this->SetDesc(_("Delete the vhost for all nicks in a group"));
this->SetSyntax(_("\037nick\037"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
const Anope::string &nick = params[0];
User *u = source.u;
NickAlias *na = findnick(nick);
if (na)
{
FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na));
NickCore *nc = na->nc;
for (std::list<NickAlias *>::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it)
{
na = *it;
na->hostinfo.RemoveVhost();
}
Log(LOG_ADMIN, u, this) << "for all nicks in group " << nc->display;
source.Reply(_("vhosts for group \002%s\002 have been removed."), nc->display.c_str());
}
else
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Deletes the vhost for all nicks in the same group as\n"
"that of the given nick."));
return true;
}
};
class HSDel : public Module
{
CommandHSDel commandhsdel;
CommandHSDelAll commandhsdelall;
public:
HSDel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE)
HSDel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
commandhsdel(this), commandhsdelall(this)
{
this->SetAuthor("Anope");
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhsdel);
ModuleManager::RegisterService(&commandhsdel);
ModuleManager::RegisterService(&commandhsdelall);
}
};