mirror of
https://github.com/anope/anope.git
synced 2026-07-04 05:33:12 +02:00
Added options:hideprivilegedcommands config option to hide privileged commands from normal users
This commit is contained in:
@@ -572,6 +572,12 @@ options
|
||||
* How long to wait between connection retries, in seconds.
|
||||
*/
|
||||
retrywait = 60
|
||||
|
||||
/*
|
||||
* If set, Services will hide commands that users doesn't have the privilege to execute
|
||||
* from HELP output.
|
||||
*/
|
||||
hideprivilegedcommands = no
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ chanserv:modules added many new cs_set_command modules
|
||||
opertype:commands added nickserv/saset/* and chanserv/saset/*
|
||||
options:socketengine added to choose what socket engine to use
|
||||
module:cs_set_misc and module:ns_set_misc added to replace the old set url/icq/email modules
|
||||
options:hideprivilegedcommands added to hide privileged commands from normal users
|
||||
|
||||
** MODIFIED CONFIGURATION DIRECTIVES **
|
||||
opertype:commands changed operserv/sgline to opserv/snline
|
||||
|
||||
@@ -555,6 +555,8 @@ class ServerConfig
|
||||
unsigned MaxRetries;
|
||||
/* How long to wait between connection attempts */
|
||||
int RetryWait;
|
||||
/* If services should hide unprivileged commands */
|
||||
bool HidePrivilegedCommands;
|
||||
|
||||
/* Services can use email */
|
||||
bool UseMail;
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ void mod_help_cmd(BotInfo *bi, User *u, const ci::string &cmd)
|
||||
|
||||
ci::string subcommand = tokens.StreamEnd() ? "" : tokens.GetRemaining().c_str();
|
||||
|
||||
if (!c || !c->OnHelp(u, subcommand))
|
||||
if (!c || (Config.HidePrivilegedCommands && !c->permission.empty() && (!u->Account() || !u->Account()->HasCommand(c->permission))) || !c->OnHelp(u, subcommand))
|
||||
notice_lang(bi->nick, u, NO_HELP_AVAILABLE, cmd.c_str());
|
||||
else
|
||||
{
|
||||
|
||||
@@ -664,6 +664,7 @@ int ServerConfig::Read(bool bail)
|
||||
{"options", "botmodes", "", new ValueContainerCIString(&Config.BotModes), DT_CISTRING, NoValidation},
|
||||
{"options", "maxretries", "10", new ValueContainerUInt(&Config.MaxRetries), DT_UINTEGER, NoValidation},
|
||||
{"options", "retrywait", "60", new ValueContainerInt(&Config.RetryWait), DT_INTEGER, ValidateNotZero},
|
||||
{"options", "hideprivilegedcommands", "no", new ValueContainerBool(&Config.HidePrivilegedCommands), DT_BOOLEAN, ValidateEmailReg},
|
||||
{"nickserv", "nick", "NickServ", new ValueContainerChar(&Config.s_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty},
|
||||
{"nickserv", "description", "Nickname Registration Service", new ValueContainerChar(&Config.desc_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty},
|
||||
{"nickserv", "emailregistration", "no", new ValueContainerBool(&Config.NSEmailReg), DT_BOOLEAN, NoValidation},
|
||||
|
||||
@@ -33,7 +33,8 @@ class CommandBSHelp : public Command
|
||||
// Abuse syntax error to display general list help.
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP);
|
||||
for (CommandMap::const_iterator it = BotServ->Commands.begin(), it_end = BotServ->Commands.end(); it != it_end; ++it)
|
||||
it->second->OnServHelp(u);
|
||||
if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission)))
|
||||
it->second->OnServHelp(u);
|
||||
notice_help(Config.s_BotServ, u, BOT_HELP_FOOTER, Config.BSMinUsers);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,7 +50,8 @@ class CommandCSHelp : public Command
|
||||
{
|
||||
notice_help(Config.s_ChanServ, u, CHAN_HELP);
|
||||
for (CommandMap::const_iterator it = ChanServ->Commands.begin(); it != ChanServ->Commands.end(); ++it)
|
||||
it->second->OnServHelp(u);
|
||||
if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission)))
|
||||
it->second->OnServHelp(u);
|
||||
if (Config.CSExpire >= 86400)
|
||||
notice_help(Config.s_ChanServ, u, CHAN_HELP_EXPIRES, Config.CSExpire / 86400);
|
||||
if (u->Account() && u->Account()->IsServicesOper())
|
||||
|
||||
@@ -31,7 +31,8 @@ class CommandHSHelp : public Command
|
||||
{
|
||||
notice_help(Config.s_HostServ, u, HOST_HELP, Config.s_HostServ);
|
||||
for (CommandMap::const_iterator it = HostServ->Commands.begin(), it_end = HostServ->Commands.end(); it != it_end; ++it)
|
||||
it->second->OnServHelp(u);
|
||||
if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission)))
|
||||
it->second->OnServHelp(u);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ class CommandMSHelp : public Command
|
||||
{
|
||||
notice_help(Config.s_MemoServ, u, MEMO_HELP_HEADER);
|
||||
for (CommandMap::const_iterator it = MemoServ->Commands.begin(), it_end = MemoServ->Commands.end(); it != it_end; ++it)
|
||||
it->second->OnServHelp(u);
|
||||
if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission)))
|
||||
it->second->OnServHelp(u);
|
||||
notice_help(Config.s_MemoServ, u, MEMO_HELP_FOOTER, Config.s_ChanServ);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,7 +42,8 @@ class CommandNSHelp : public Command
|
||||
{
|
||||
notice_help(Config.s_NickServ, u, NICK_HELP);
|
||||
for (CommandMap::const_iterator it = NickServ->Commands.begin(), it_end = NickServ->Commands.end(); it != it_end; ++it)
|
||||
it->second->OnServHelp(u);
|
||||
if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission)))
|
||||
it->second->OnServHelp(u);
|
||||
if (u->Account() && u->Account()->IsServicesOper())
|
||||
notice_help(Config.s_NickServ, u, NICK_SERVADMIN_HELP);
|
||||
if (Config.NSExpire >= 86400)
|
||||
|
||||
@@ -30,7 +30,8 @@ class CommandOSHelp : public Command
|
||||
{
|
||||
notice_help(Config.s_OperServ, u, OPER_HELP);
|
||||
for (CommandMap::const_iterator it = OperServ->Commands.begin(), it_end = OperServ->Commands.end(); it != it_end; ++it)
|
||||
it->second->OnServHelp(u);
|
||||
if (!Config.HidePrivilegedCommands || it->second->permission.empty() || (u->Account() && u->Account()->HasCommand(it->second->permission)))
|
||||
it->second->OnServHelp(u);
|
||||
notice_help(Config.s_OperServ, u, OPER_HELP_LOGGED);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user