diff options
Diffstat (limited to 'ClientInfo.hpp')
| -rw-r--r-- | ClientInfo.hpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/ClientInfo.hpp b/ClientInfo.hpp index e2c7864..8099b59 100644 --- a/ClientInfo.hpp +++ b/ClientInfo.hpp @@ -1,5 +1,6 @@ #pragma once +#include <QDateTime> #include <QString> enum ClientInterface { @@ -30,6 +31,8 @@ public: QString pcName = ""; bool activated = false; + QList<QDateTime> antiFloodList; + QString target = ""; ManagementConnection management; @@ -52,7 +55,7 @@ public: ClientInfo ret; ret.interface = Clonk; ret.nick = nick; - ret.nick = pcName; + ret.pcName = pcName; ret.CUID = CUID; ret.activated = activated; return ret; @@ -84,8 +87,26 @@ public: return !operator==(other); } + inline bool operator<(const ClientInfo& other) const + { + return toString() < other.toString(); + } + inline QString toString() const { return interface == Auto ? "~auto~" : interface == Management ? management.name + " {CLI}" : (!nick.isEmpty() ? nick + (interface == Clonk ? " (" + pcName + ")" : " [IRC]") : ""); } + + inline bool floodCheck(int maxCount, int floodTimeSecs, QDateTime newDateTime = QDateTime::currentDateTime()) + { + foreach(const QDateTime& dateTime, antiFloodList) + { + if(dateTime.secsTo(newDateTime) > floodTimeSecs) + { + antiFloodList.removeAll(dateTime); + } + } + antiFloodList.push_back(newDateTime); + return antiFloodList.size() > maxCount; + } }; |
