summaryrefslogtreecommitdiffstats
path: root/src/crsm.cpp
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2015-11-08 02:03:31 +0100
committerMarkus Mittendrein <git@maxmitti.tk>2015-11-08 03:04:38 +0100
commit7f8ded233bba4b803eb787526c59a69477dce068 (patch)
treec532f8af017c896b1285d54e2226f1cba122b002 /src/crsm.cpp
parentb63aed7253a307a4011d2a39e51dcc584e90d372 (diff)
downloadmanager-7f8ded233bba4b803eb787526c59a69477dce068.tar.gz
manager-7f8ded233bba4b803eb787526c59a69477dce068.zip
Allow optional suffixes for commands (e.g. for punctuation marks)
Diffstat (limited to 'src/crsm.cpp')
-rw-r--r--src/crsm.cpp23
1 files changed, 22 insertions, 1 deletions
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)