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:
+50
-16
@@ -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> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
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> ¶ms)
|
||||
{
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user