summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2016-05-05 02:31:36 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2016-05-05 02:31:36 +0200
commite6589b85c6754e454257657c846a17d6f7983da5 (patch)
tree79aba655c9c6741049a6a9134f305dd36568d356 /src
parent9e064af34b2223545ac82d7c554a7b52103637eb (diff)
downloadmanager-e6589b85c6754e454257657c846a17d6f7983da5.tar.gz
manager-e6589b85c6754e454257657c846a17d6f7983da5.zip
Add recursive option to help command (only for Management-Interface)
Diffstat (limited to 'src')
-rw-r--r--src/crsm.cpp59
1 files changed, 56 insertions, 3 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp
index be06197..2e1d6c0 100644
--- a/src/crsm.cpp
+++ b/src/crsm.cpp
@@ -2000,14 +2000,67 @@ bool CRSM::greetAllowed(const ClientInfo &client)
}
CMD_FUNCTION_IMPL(help)
- bool longHelp = (args == "long");
+ bool recursive = args.startsWith("recursive ") && client.interface == Management;
+ ClientInterface interface = client.interface;
+ if(recursive)
+ {
+ const QStringList& options = args.mid(QString("recursive ").length()).split(' ');
+ if(options.length() >= 1)
+ {
+ const QString& interfaceStr = options.first();
+ if(interfaceStr == "Clonk")
+ {
+ interface = Clonk;
+ }
+ else if(interfaceStr == "IRC")
+ {
+ interface = IRC;
+ }
+ else if(interfaceStr == "Management")
+ {
+ interface = Management;
+ }
+ else
+ {
+ respond(client, "Error parsing unknown interface option for recursive help: " + interfaceStr + "\n");
+ return SyntaxFail;
+ }
+
+ if(options.length() >= 2)
+ {
+ const QString& typeStr = options.at(1);
+ if(typeStr == "User")
+ {
+ userType = User;
+ }
+ else if(typeStr == "Admin")
+ {
+ userType = Admin;
+ }
+ else if(typeStr == "Moderator")
+ {
+ userType = Moderator;
+ }
+ else
+ {
+ respond(client, "Error parsing unknown user type option for recursive help: " + typeStr + "\n");
+ return SyntaxFail;
+ }
+ }
+ }
+ }
+ else if(args.endsWith("recursive") && client.interface == Management)
+ {
+ recursive = true;
+ }
+ bool longHelp = recursive || (args == "long");
if(args.isEmpty() || longHelp)
{
QString response = "Verfügbare Befehle: ";
foreach(const CmdFunctionRef& cmd, cmds)
{
- if(cmd.name.contains(' ')) continue;
- if((cmd.interfaces & client.interface) == client.interface && userType >= cmd.userType)
+ if(!recursive && cmd.name.contains(' ')) continue;
+ if((cmd.interfaces & interface) == interface && ((recursive && userType == cmd.userType) || (!recursive && userType >= cmd.userType)))
{
if(longHelp)
{