mirror of
https://github.com/anope/anope.git
synced 2026-07-01 18:46:39 +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,21 +12,31 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
#include "chanserv.h"
|
||||
|
||||
class CommandCSSetSecure : public Command
|
||||
{
|
||||
public:
|
||||
CommandCSSetSecure(const Anope::string &cpermission = "") : Command("SECURE", 2, 2, cpermission)
|
||||
CommandCSSetSecure(Module *creator, const Anope::string &cname = "chanserv/set/secure", const Anope::string &cpermission = "") : Command(creator, cname, 2, 2, cpermission)
|
||||
{
|
||||
this->SetDesc(Anope::printf(_("Activate %s's security features"), Config->s_ChanServ.c_str()));
|
||||
this->SetDesc(_("Activate security features"));
|
||||
this->SetSyntax(_("\037channel\037 SECURE {ON | OFF}"));
|
||||
}
|
||||
|
||||
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
ChannelInfo *ci = source.ci;
|
||||
if (!ci)
|
||||
throw CoreException("NULL ci in CommandCSSetSecure");
|
||||
User *u = source.u;
|
||||
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 (params[1].equals_ci("ON"))
|
||||
{
|
||||
@@ -41,38 +51,28 @@ class CommandCSSetSecure : public Command
|
||||
else
|
||||
this->OnSyntaxError(source, "SECURE");
|
||||
|
||||
return MOD_CONT;
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &)
|
||||
{
|
||||
source.Reply(_("Syntax: \002%s \037channel\037 SECURE {ON | OFF}\002\n"
|
||||
" \n"
|
||||
"Enables or disables %s's security features for a\n"
|
||||
"channel. When \002SECURE\002 is set, only users who have\n"
|
||||
"registered their nicknames with %s and IDENTIFY'd\n"
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Enables or disables security features for a\n"
|
||||
"channel. When \002%s\002 is set, only users who have\n"
|
||||
"registered their nicknames and IDENTIFY'd\n"
|
||||
"with their password will be given access to the channel\n"
|
||||
"as controlled by the access list."), this->name.c_str(), Config->s_NickServ.c_str(), Config->s_NickServ.c_str());
|
||||
"as controlled by the access list."), this->name.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnSyntaxError(CommandSource &source, const Anope::string &)
|
||||
{
|
||||
SyntaxError(source, "SET SECURE", _("SET \037channel\037 SECURE {ON | OFF}"));
|
||||
}
|
||||
};
|
||||
|
||||
class CommandCSSASetSecure : public CommandCSSetSecure
|
||||
{
|
||||
public:
|
||||
CommandCSSASetSecure() : CommandCSSetSecure("chanserv/saset/secure")
|
||||
CommandCSSASetSecure(Module *creator) : CommandCSSetSecure(creator, "chanserv/saset/secure", "chanserv/saset/secure")
|
||||
{
|
||||
}
|
||||
|
||||
void OnSyntaxError(CommandSource &source, const Anope::string &)
|
||||
{
|
||||
SyntaxError(source, "SASET SECURE", _("SASET \002channel\002 SECURE {ON | OFF}"));
|
||||
}
|
||||
};
|
||||
|
||||
class CSSetSecure : public Module
|
||||
@@ -81,31 +81,13 @@ class CSSetSecure : public Module
|
||||
CommandCSSASetSecure commandcssasetsecure;
|
||||
|
||||
public:
|
||||
CSSetSecure(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE)
|
||||
CSSetSecure(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandcssetsecure(this), commandcssasetsecure(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
|
||||
if (!chanserv)
|
||||
throw ModuleException("ChanServ is not loaded!");
|
||||
|
||||
Command *c = FindCommand(chanserv->Bot(), "SET");
|
||||
if (c)
|
||||
c->AddSubcommand(this, &commandcssetsecure);
|
||||
|
||||
c = FindCommand(chanserv->Bot(), "SASET");
|
||||
if (c)
|
||||
c->AddSubcommand(this, &commandcssasetsecure);
|
||||
}
|
||||
|
||||
~CSSetSecure()
|
||||
{
|
||||
Command *c = FindCommand(chanserv->Bot(), "SET");
|
||||
if (c)
|
||||
c->DelSubcommand(&commandcssetsecure);
|
||||
|
||||
c = FindCommand(chanserv->Bot(), "SASET");
|
||||
if (c)
|
||||
c->DelSubcommand(&commandcssasetsecure);
|
||||
ModuleManager::RegisterService(&commandcssetsecure);
|
||||
ModuleManager::RegisterService(&commandcssasetsecure);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user