summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CRSMConfig.hpp2
-rw-r--r--src/crsm.cpp23
-rw-r--r--src/crsm.hpp1
3 files changed, 25 insertions, 1 deletions
diff --git a/src/CRSMConfig.hpp b/src/CRSMConfig.hpp
index 576447d..921e56e 100644
--- a/src/CRSMConfig.hpp
+++ b/src/CRSMConfig.hpp
@@ -12,6 +12,7 @@ public:
String SessionFile = "CrServerManager.session";
String PacksFile = "CrServerManager.packs";
Map(String, String) CommandAlias;
+ List(String) CommandSuffixes;
} CRSM;
struct {
@@ -96,6 +97,7 @@ public:
ConfigVal(CRSM.SessionFile),
ConfigVal(CRSM.PacksFile),
ConfigVal(CRSM.CommandAlias),
+ ConfigVal(CRSM.CommandSuffixes),
diff --git a/src/crsm.cpp b/src/crsm.cpp
index 021a63b..e99fabb 100644
--- a/src/crsm.cpp
+++ b/src/crsm.cpp
@@ -1244,7 +1244,7 @@ CmdFunctionRef* CRSM::findCommand(QStringList&& cmd, ClientInterface interface,
}
}
-bool CRSM::cmd(QString cmd, const ClientInfo &client)
+bool CRSM::cmd(const QString& cmd, const ClientInfo &client)
{
CmdFunctionRef* cmdPtr;
QString realCmd = cmd;
@@ -1252,6 +1252,7 @@ bool CRSM::cmd(QString cmd, const ClientInfo &client)
{
CmdFunctionRef cmdRef = *cmdPtr;
QString args = cmd.mid(realCmd.length()).trimmed();
+ removeCommandSuffixes(args);
switch(client.interface)
{
case Clonk:
@@ -1827,6 +1828,26 @@ bool CRSM::isChannelName(const QString &name)
}
}
+void CRSM::removeCommandSuffixes(QString& command)
+{
+ foreach(const QString& suffix, Config.CRSM.CommandSuffixes)
+ {
+ if(command.length() > suffix.length() && command.right(suffix.length()) == suffix)
+ {
+ command.chop(suffix.length());
+ break;
+ }
+ }
+}
+
+void CRSM::substituteCommandAlias(QString &command)
+{
+ while(Config.CRSM.CommandAlias.contains(command))
+ {
+ command = Config.CRSM.CommandAlias.value(command);
+ }
+}
+
CMD_FUNCTION_IMPL(help)
bool longHelp = (args == "long");
if(args.isEmpty() || longHelp)
diff --git a/src/crsm.hpp b/src/crsm.hpp
index 56f2a29..56d9b18 100644
--- a/src/crsm.hpp
+++ b/src/crsm.hpp
@@ -291,6 +291,7 @@ private:
int findWishFromUser(const ClientInfo& client);
QString getCommand(const QString& message);
bool isChannelName(const QString& name);
+ void removeCommandSuffixes(QString& command);
void substituteCommandAlias(QString& command);
CMD_FUNCTION(help);