|
@@ -28,7 +28,7 @@ along with this program. If not, see < http://www.gnu.org/licenses/ >.
|
|
|
#include "Settings.h"
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
-Client::Client(App *app, ActiveClient* ac, bool supportsSendPrivate):
|
|
|
+Client::Client(App *app, ActiveClient* ac):
|
|
|
QWClient(),
|
|
|
myActiveClient(ac),
|
|
|
myApp(app),
|
|
@@ -40,7 +40,8 @@ Client::Client(App *app, ActiveClient* ac, bool supportsSendPrivate):
|
|
|
myFloodTimer(new QTimer()),
|
|
|
myQWBroadcastFloodTimer(new QTimer()),
|
|
|
mySpamBroadcastFloodTimer(new QTimer()),
|
|
|
- mySupportsSendPrivate(supportsSendPrivate),
|
|
|
+ mySPSupport(false),
|
|
|
+ myAutoDetectSP(true),
|
|
|
myMaxClients(0)
|
|
|
{
|
|
|
myKeepNickTimer->setSingleShot(true);
|
|
@@ -71,7 +72,7 @@ void Client::say(const QString &msg, const QString &nickName)
|
|
|
{
|
|
|
QString cmd("say ");
|
|
|
|
|
|
- if(!nickName.isEmpty() && mySupportsSendPrivate)
|
|
|
+ if(!nickName.isEmpty() && mySPSupport)
|
|
|
cmd.append("s-p \"" + nickName + "\" ");
|
|
|
|
|
|
cmd.append(msg);
|
|
@@ -133,6 +134,23 @@ bool Client::isSpamMuted() const
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
void Client::parsePrintedLine()
|
|
|
{
|
|
|
+ // Detects whether s-p command is supported
|
|
|
+ if(mySPDetectionTimer->isActive())
|
|
|
+ {
|
|
|
+ if(myPrintLine.startsWith(Settings::globalInstance()->botName() + ": s-p"))
|
|
|
+ {
|
|
|
+ mySPSupport = false;
|
|
|
+ mySPDetectionTimer->stop();
|
|
|
+ setAutoDetectSP(false); // Don't try detecting again on next map
|
|
|
+ }
|
|
|
+ else if(myPrintLine.startsWith("usage: s-p id/name txt"))
|
|
|
+ {
|
|
|
+ mySPSupport = true;
|
|
|
+ mySPDetectionTimer->stop();
|
|
|
+ setAutoDetectSP(false); // Don't try detecting again on next map
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// Find the player that printed this line of text
|
|
|
Player player, bestPlayer;
|
|
|
quint16 lastMatchSize = 0;
|
|
@@ -168,22 +186,6 @@ void Client::parsePrintedLine()
|
|
|
|
|
|
QString message(myPrintLine.right(myPrintLine.size() - lastMatchSize));
|
|
|
|
|
|
- // Detects whether s-p command is supported
|
|
|
- if(mySPDetectionActive)
|
|
|
- {
|
|
|
- if(mySPDetectionTimer->isActive() && nick == Settings::globalInstance()->botName() && message == "s-p")
|
|
|
- {
|
|
|
- mySupportsSendPrivate = false;
|
|
|
- mySPDetectionTimer->stop();
|
|
|
- mySPDetectionActive = false;
|
|
|
- }
|
|
|
- else if(!mySPDetectionTimer->isActive())
|
|
|
- {
|
|
|
- mySupportsSendPrivate = true;
|
|
|
- mySPDetectionTimer->stop();
|
|
|
- mySPDetectionActive = false;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
QRegExp regex("^:\\s+\\.(spam|qw|help|qw_mute|qw_unmute|spam_mute|spam_unmute|lm)\\s*(.+)$");
|
|
|
if(regex.indexIn(message) == -1)
|
|
@@ -469,7 +471,8 @@ void Client::onStuffedCmd(const char *cmd)
|
|
|
myOnServerFlag = true;
|
|
|
|
|
|
setPing(Settings::globalInstance()->botPing());
|
|
|
- spDetection();
|
|
|
+ if(myAutoDetectSP)
|
|
|
+ spDetection();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -497,9 +500,9 @@ void Client::onDownloadFinished()
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
-bool Client::supportsSendPrivate() const
|
|
|
+void Client::setAutoDetectSP(bool autoDetect)
|
|
|
{
|
|
|
- return mySupportsSendPrivate;
|
|
|
+ myAutoDetectSP = autoDetect;
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -508,7 +511,6 @@ void Client::spDetection()
|
|
|
say("s-p");
|
|
|
mySPDetectionTimer->setSingleShot(true);
|
|
|
mySPDetectionTimer->start(2000);
|
|
|
- mySPDetectionActive = true;
|
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|