summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2016-10-08 15:02:29 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2016-10-08 15:02:29 +0200
commit7a360359b4bd84626bc832c46efc2dfdcfaae0b9 (patch)
tree27ee4ad16e5b3bdd9c4a1fcb27f082e1c017f0f0
parentfd13a641916f81721f29da91277506da89c67542 (diff)
downloadmanager-7a360359b4bd84626bc832c46efc2dfdcfaae0b9.tar.gz
manager-7a360359b4bd84626bc832c46efc2dfdcfaae0b9.zip
Remove timestamp from clonk messages manually without RegExp
-rw-r--r--src/crsm.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp
index 865cd7b..bfe2991 100644
--- a/src/crsm.cpp
+++ b/src/crsm.cpp
@@ -98,8 +98,7 @@ bool CRSM::isOk()
void CRSM::readServerOutput()
{
- static QRegExp timeRemover("^>?\\s*\\[(\\d\\d:\\d\\d:\\d\\d)\\]\\s+(.*)$");
- QString what(processManager->readLine());
+ QString what(processManager->readLine().trimmed());
if(Config.Readline.ServerUses)
{
@@ -110,7 +109,10 @@ void CRSM::readServerOutput()
}
if(what.at(0) == '>')
+ {
what.remove(0, 1);
+ }
+ what = what.trimmed();
}
if(what.isEmpty())
@@ -124,10 +126,15 @@ void CRSM::readServerOutput()
sendIrcMessage(mess, mod, false, true, true);
}
}
- out(what.trimmed() + "\n");
- if(!timeRemover.exactMatch(what))
+ out(what + "\n");
+ if(what.length() < 12 || what.at(0) != '[' || what.at(9) != ']' || what.at(10) != ' ')
+ {
return;
- what = timeRemover.cap(2).trimmed();
+ }
+
+ const QTime& msgTime = QTime::fromString(what.mid(1, 8), "hh:mm:ss");
+ what = what.mid(11);
+
Log.clonkLog(what);
static QRegExp userexp("^\\s*(\\*?)\\s*<(.*)\\|(\\d+)\\|([^>]*)>\\s+(.*)$");
@@ -147,7 +154,7 @@ void CRSM::readServerOutput()
checkActivity(Session.Clonk.Admin);
}
QString msg = userexp.cap(5).trimmed();
- if(info.floodCheck(Config.Clonk.Chat.AntiFlood.Count, Config.Clonk.Chat.AntiFlood.Time, QDateTime(QDate::currentDate(), QTime::fromString(timeRemover.cap(1), "hh:mm:ss"))))
+ if(info.floodCheck(Config.Clonk.Chat.AntiFlood.Count, Config.Clonk.Chat.AntiFlood.Time, QDateTime(QDate::currentDate(), msgTime)))
{
kick(pcName, "Flooding! Maximal " + QString::number(Config.Clonk.Chat.AntiFlood.Count) + " Nachrichten in " + QString::number(Config.Clonk.Chat.AntiFlood.Time) + "s");
}