|
@@ -18,27 +18,33 @@ Client::Client(App *app, ActiveClient* ac):
|
|
myQWMutedFlag(false),
|
|
myQWMutedFlag(false),
|
|
myJoinMessageTimer(new QTimer()),
|
|
myJoinMessageTimer(new QTimer()),
|
|
myKeepNickTimer(new QTimer()),
|
|
myKeepNickTimer(new QTimer()),
|
|
|
|
+ myFloodTimer(new QTimer()),
|
|
|
|
+ myQWBroadcastFloodTimer(new QTimer()),
|
|
|
|
+ mySpamBroadcastFloodTimer(new QTimer()),
|
|
myJoinMessagePrinted(false),
|
|
myJoinMessagePrinted(false),
|
|
myJoinMessageScheduled(false),
|
|
myJoinMessageScheduled(false),
|
|
myMaxClients(0)
|
|
myMaxClients(0)
|
|
{
|
|
{
|
|
myJoinMessageTimer->setSingleShot(true);
|
|
myJoinMessageTimer->setSingleShot(true);
|
|
myKeepNickTimer->setSingleShot(true);
|
|
myKeepNickTimer->setSingleShot(true);
|
|
|
|
+ myFloodTimer->setSingleShot(true);
|
|
|
|
+ myQWBroadcastFloodTimer->setSingleShot(true);
|
|
|
|
+ mySpamBroadcastFloodTimer->setSingleShot(true);
|
|
}
|
|
}
|
|
|
|
|
|
Client::~Client()
|
|
Client::~Client()
|
|
{
|
|
{
|
|
delete myJoinMessageTimer;
|
|
delete myJoinMessageTimer;
|
|
|
|
+ delete myKeepNickTimer;
|
|
|
|
+ delete myFloodTimer;
|
|
|
|
+ delete myQWBroadcastFloodTimer;
|
|
|
|
+ delete mySpamBroadcastFloodTimer;
|
|
}
|
|
}
|
|
|
|
|
|
void Client::connect(const char *host, quint16 port)
|
|
void Client::connect(const char *host, quint16 port)
|
|
{
|
|
{
|
|
myJoinMessageScheduled = true; //Hi message only scheduled at bot connection
|
|
myJoinMessageScheduled = true; //Hi message only scheduled at bot connection
|
|
|
|
|
|
- myEndFloodTime = QTime::currentTime();
|
|
|
|
- myQWBroadcastFloodTime = myEndFloodTime;
|
|
|
|
- mySpamBroadcastFloodTime = myEndFloodTime;
|
|
|
|
-
|
|
|
|
QWClient::connect(host, port);
|
|
QWClient::connect(host, port);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -154,18 +160,18 @@ void Client::parsePrintedLine()
|
|
|
|
|
|
/* Flood prot */
|
|
/* Flood prot */
|
|
QTime currentTime = QTime::currentTime();
|
|
QTime currentTime = QTime::currentTime();
|
|
-
|
|
|
|
- int timeLeft = currentTime.secsTo(myEndFloodTime);
|
|
|
|
- if(timeLeft > 0)
|
|
|
|
|
|
+ int floodProtTime = Settings::globalInstance()->floodProtTime();
|
|
|
|
+ if(myFloodTimer->isActive())
|
|
{
|
|
{
|
|
if(!myFloodMsgPrinted)
|
|
if(!myFloodMsgPrinted)
|
|
{
|
|
{
|
|
- say("> FloodProt: Not so fast, wait " + QString::number(timeLeft) + " sec(s).");
|
|
|
|
|
|
+ say("> FloodProt: Not so fast, wait " + QString::number(floodProtTime + currentTime.secsTo(myFloodTimerStart)) + " sec(s).");
|
|
myFloodMsgPrinted = true;
|
|
myFloodMsgPrinted = true;
|
|
}
|
|
}
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- myEndFloodTime = currentTime.addSecs(Settings::globalInstance()->floodProtTime());
|
|
|
|
|
|
+ myFloodTimerStart = currentTime;
|
|
|
|
+ myFloodTimer->start(floodProtTime*1000);
|
|
myFloodMsgPrinted = false;
|
|
myFloodMsgPrinted = false;
|
|
|
|
|
|
QString command = regex.capturedTexts().at(1);
|
|
QString command = regex.capturedTexts().at(1);
|
|
@@ -190,25 +196,28 @@ void Client::parsePrintedLine()
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /* Floodprot for broadcasting commands */
|
|
if(command == "qw")
|
|
if(command == "qw")
|
|
{
|
|
{
|
|
- timeLeft = currentTime.secsTo(myQWBroadcastFloodTime);
|
|
|
|
- if(timeLeft > 0)
|
|
|
|
|
|
+ int qwFloodProtTime = Settings::globalInstance()->qwFloodProtTime();
|
|
|
|
+ if(myQWBroadcastFloodTimer->isActive())
|
|
{
|
|
{
|
|
- say("> FloodProt: Wait " + QString::number(timeLeft) + " secs before new .qw");
|
|
|
|
|
|
+ say("> FloodProt: Wait " + QString::number(qwFloodProtTime + currentTime.secsTo(myQWBroadcastFloodTimerStart)) + " secs before new .qw");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- myQWBroadcastFloodTime = currentTime.addSecs(Settings::globalInstance()->qwFloodProtTime());
|
|
|
|
|
|
+ myQWBroadcastFloodTimerStart = currentTime;
|
|
|
|
+ myQWBroadcastFloodTimer->start(qwFloodProtTime*1000);
|
|
}
|
|
}
|
|
else if(command == "spam")
|
|
else if(command == "spam")
|
|
{
|
|
{
|
|
- timeLeft = currentTime.secsTo(mySpamBroadcastFloodTime);
|
|
|
|
- if(timeLeft > 0)
|
|
|
|
|
|
+ int spamFloodProtTime = Settings::globalInstance()->spamFloodProtTime();
|
|
|
|
+ if(mySpamBroadcastFloodTimer->isActive())
|
|
{
|
|
{
|
|
- say("> FloodProt: Wait " + QString::number(timeLeft) + " secs before new .spam");
|
|
|
|
|
|
+ say("> FloodProt: Wait " + QString::number(spamFloodProtTime + currentTime.secsTo(mySpamBroadcastFloodTimerStart)) + " secs before new .spam");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- mySpamBroadcastFloodTime = currentTime.addSecs(Settings::globalInstance()->spamFloodProtTime());
|
|
|
|
|
|
+ mySpamBroadcastFloodTimerStart = currentTime;
|
|
|
|
+ mySpamBroadcastFloodTimer->start(spamFloodProtTime*1000);
|
|
}
|
|
}
|
|
|
|
|
|
QString server(QString(host()) + ":" + QString::number(port()) + " " + QString::number(playerCount()) + "/" + QString::number(myMaxClients));
|
|
QString server(QString(host()) + ":" + QString::number(port()) + " " + QString::number(playerCount()) + "/" + QString::number(myMaxClients));
|
|
@@ -383,19 +392,6 @@ void Client::run()
|
|
myKeepNickTimer->start(30000);
|
|
myKeepNickTimer->start(30000);
|
|
}
|
|
}
|
|
|
|
|
|
- /* Avoid wrap around of flood timers */
|
|
|
|
- QTime currentTime = QTime::currentTime();
|
|
|
|
- // qDebug() << currentTime.secsTo(myEndFloodTime);
|
|
|
|
-
|
|
|
|
- if(currentTime.secsTo(myEndFloodTime) < -16000)
|
|
|
|
- myEndFloodTime = currentTime;
|
|
|
|
-
|
|
|
|
- if(currentTime.secsTo(myQWBroadcastFloodTime) < -16000)
|
|
|
|
- myQWBroadcastFloodTime = currentTime;
|
|
|
|
-
|
|
|
|
- if(currentTime.secsTo(mySpamBroadcastFloodTime) < -16000)
|
|
|
|
- mySpamBroadcastFloodTime = currentTime;
|
|
|
|
-
|
|
|
|
QWClient::run();
|
|
QWClient::run();
|
|
}
|
|
}
|
|
|
|
|