|
@@ -41,13 +41,16 @@ Client::Client(App *app, ActiveClient* ac):
|
|
|
myQWBroadcastFloodTimer(new QTimer()),
|
|
|
mySpamBroadcastFloodTimer(new QTimer()),
|
|
|
mySPSupport(false),
|
|
|
- myAutoDetectSP(true),
|
|
|
- myMaxClients(0)
|
|
|
+ mySPAutoDetect(true),
|
|
|
+ myMaxClients(0),
|
|
|
+ myCmdScheduledTimer(new QTimer())
|
|
|
{
|
|
|
myKeepNickTimer->setSingleShot(true);
|
|
|
myFloodTimer->setSingleShot(true);
|
|
|
myQWBroadcastFloodTimer->setSingleShot(true);
|
|
|
mySpamBroadcastFloodTimer->setSingleShot(true);
|
|
|
+ mySPDetectionTimer->setSingleShot(true);
|
|
|
+ myCmdScheduledTimer->setSingleShot(true);
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -58,6 +61,7 @@ Client::~Client()
|
|
|
delete myQWBroadcastFloodTimer;
|
|
|
delete mySpamBroadcastFloodTimer;
|
|
|
delete mySPDetectionTimer;
|
|
|
+ delete myCmdScheduledTimer;
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -446,13 +450,27 @@ void Client::run()
|
|
|
// myJoinMessagePrinted = true;
|
|
|
// }
|
|
|
|
|
|
- /* Keep nick... Simply set name again after 30 secs */
|
|
|
+ // Keep nick... Simply set name again after 30 secs
|
|
|
if(!myKeepNickTimer->isActive())
|
|
|
{
|
|
|
setName(Settings::globalInstance()->botName().toAscii().data());
|
|
|
myKeepNickTimer->start(30000);
|
|
|
}
|
|
|
|
|
|
+ // Scheduled commands
|
|
|
+ if(!myCmdScheduled.isEmpty() && !myCmdScheduledTimer->isActive())
|
|
|
+ {
|
|
|
+ if(myCmdScheduled == "say s-p")
|
|
|
+ {
|
|
|
+ say("s-p");
|
|
|
+ mySPDetectionTimer->start(2000);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ sendCmd(myCmdScheduled.toAscii().data());
|
|
|
+
|
|
|
+ myCmdScheduled.clear();
|
|
|
+ }
|
|
|
+
|
|
|
QWClient::run();
|
|
|
}
|
|
|
|
|
@@ -471,7 +489,7 @@ void Client::onStuffedCmd(const char *cmd)
|
|
|
myOnServerFlag = true;
|
|
|
|
|
|
setPing(Settings::globalInstance()->botPing());
|
|
|
- if(myAutoDetectSP)
|
|
|
+ if(mySPAutoDetect)
|
|
|
spDetection();
|
|
|
}
|
|
|
}
|
|
@@ -502,15 +520,13 @@ void Client::onDownloadFinished()
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
void Client::setAutoDetectSP(bool autoDetect)
|
|
|
{
|
|
|
- myAutoDetectSP = autoDetect;
|
|
|
+ mySPAutoDetect = autoDetect;
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
void Client::spDetection()
|
|
|
{
|
|
|
- say("s-p");
|
|
|
- mySPDetectionTimer->setSingleShot(true);
|
|
|
- mySPDetectionTimer->start(2000);
|
|
|
+ scheduleCmd("say s-p", 2000);
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -521,3 +537,10 @@ QString Client::parseNameFun(const QString &string)
|
|
|
|
|
|
return QString(b);
|
|
|
}
|
|
|
+
|
|
|
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
+void Client::scheduleCmd(const QString &cmd, int time)
|
|
|
+{
|
|
|
+ myCmdScheduled = cmd;
|
|
|
+ myCmdScheduledTimer->start(time);
|
|
|
+}
|