|
@@ -41,8 +41,7 @@ Client::Client(App *app, ActiveClient* ac):
|
|
myQWMutedFlag(false),
|
|
myQWMutedFlag(false),
|
|
myKeepNickTimer(new QTimer()),
|
|
myKeepNickTimer(new QTimer()),
|
|
myFloodTimer(new QTimer()),
|
|
myFloodTimer(new QTimer()),
|
|
- myQWBroadcastFloodTimer(new QTimer()),
|
|
|
|
- mySpamBroadcastFloodTimer(new QTimer()),
|
|
|
|
|
|
+ myBroadcastFloodTimer(new QTimer()),
|
|
mySPDetectionTimer(new QTimer()),
|
|
mySPDetectionTimer(new QTimer()),
|
|
mySPSupport(false),
|
|
mySPSupport(false),
|
|
mySPAutoDetect(true),
|
|
mySPAutoDetect(true),
|
|
@@ -52,8 +51,7 @@ Client::Client(App *app, ActiveClient* ac):
|
|
rxBrackets.setMinimal(true);
|
|
rxBrackets.setMinimal(true);
|
|
myKeepNickTimer->setSingleShot(true);
|
|
myKeepNickTimer->setSingleShot(true);
|
|
myFloodTimer->setSingleShot(true);
|
|
myFloodTimer->setSingleShot(true);
|
|
- myQWBroadcastFloodTimer->setSingleShot(true);
|
|
|
|
- mySpamBroadcastFloodTimer->setSingleShot(true);
|
|
|
|
|
|
+ myBroadcastFloodTimer->setSingleShot(true);
|
|
mySPDetectionTimer->setSingleShot(true);
|
|
mySPDetectionTimer->setSingleShot(true);
|
|
myCmdScheduledTimer->setSingleShot(true);
|
|
myCmdScheduledTimer->setSingleShot(true);
|
|
}
|
|
}
|
|
@@ -63,8 +61,7 @@ Client::~Client()
|
|
{
|
|
{
|
|
delete myKeepNickTimer;
|
|
delete myKeepNickTimer;
|
|
delete myFloodTimer;
|
|
delete myFloodTimer;
|
|
- delete myQWBroadcastFloodTimer;
|
|
|
|
- delete mySpamBroadcastFloodTimer;
|
|
|
|
|
|
+ delete myBroadcastFloodTimer;
|
|
delete mySPDetectionTimer;
|
|
delete mySPDetectionTimer;
|
|
delete myCmdScheduledTimer;
|
|
delete myCmdScheduledTimer;
|
|
}
|
|
}
|
|
@@ -208,7 +205,7 @@ void Client::parsePrintedLine()
|
|
QString message(myPrintLine.right(myPrintLine.size() - lastMatchSize));
|
|
QString message(myPrintLine.right(myPrintLine.size() - lastMatchSize));
|
|
|
|
|
|
|
|
|
|
- QRegExp regex("^:\\s+\\.(spam|qw|help|qw_mute|qw_unmute|spam_mute|spam_unmute|lm)\\s*(.+)$");
|
|
|
|
|
|
+ QRegExp regex("^:\\s+\\.(spam|qw|help|qw_mute|qw_unmute|spam_mute|spam_unmute|lm|about)\\s*(.+)$");
|
|
if(regex.indexIn(message) == -1)
|
|
if(regex.indexIn(message) == -1)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -236,7 +233,13 @@ void Client::parsePrintedLine()
|
|
say("Broadcast a message: .qw <message> and .spam <message>", bestPlayer.name);
|
|
say("Broadcast a message: .qw <message> and .spam <message>", bestPlayer.name);
|
|
say("(Un)Mute: .qw_mute .qw_unmute or .spam_mute .spam_unmute", bestPlayer.name);
|
|
say("(Un)Mute: .qw_mute .qw_unmute or .spam_mute .spam_unmute", bestPlayer.name);
|
|
say("Last 5 messages: .lm", bestPlayer.name);
|
|
say("Last 5 messages: .lm", bestPlayer.name);
|
|
|
|
+ say("About this bot: .about", bestPlayer.name);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if(command == "about")
|
|
|
|
+ {
|
|
|
|
+ say("ServeMe specbots by mihawk & Haudraufwienix, find us on #qwnet @ irc.quakenet.org", bestPlayer.name);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -249,30 +252,21 @@ void Client::parsePrintedLine()
|
|
}
|
|
}
|
|
|
|
|
|
/* Floodprot for broadcasting commands */
|
|
/* Floodprot for broadcasting commands */
|
|
- if(command == "qw")
|
|
|
|
|
|
+ if(command == "qw" || command == "spam")
|
|
{
|
|
{
|
|
- int qwFloodProtTime = Settings::globalInstance()->qwFloodProtTime();
|
|
|
|
- if(myQWBroadcastFloodTimer->isActive())
|
|
|
|
|
|
+ if(myBroadcastFloodTimer->isActive())
|
|
{
|
|
{
|
|
- say("FloodProt: Wait " + QString::number(qwFloodProtTime + currentTime.secsTo(myQWBroadcastFloodTimerStart)) + " secs before new .qw", bestPlayer.name);
|
|
|
|
|
|
+ say("FloodProt: Wait " + QString::number(myBroadcastFloodTimer->interval()/1000 + currentTime.secsTo(myBroadcastFloodTimerStart)) + " sec(s) before issuing a new " + command, bestPlayer.name);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- myQWBroadcastFloodTimerStart = currentTime;
|
|
|
|
- myQWBroadcastFloodTimer->start(qwFloodProtTime*1000);
|
|
|
|
- }
|
|
|
|
- else if(command == "spam")
|
|
|
|
- {
|
|
|
|
- say("Only .qw is allowed within QW servers. Please use .qw to broadcast your message.");
|
|
|
|
- return;
|
|
|
|
|
|
|
|
-// int spamFloodProtTime = Settings::globalInstance()->spamFloodProtTime();
|
|
|
|
-// if(mySpamBroadcastFloodTimer->isActive())
|
|
|
|
-// {
|
|
|
|
-// say("FloodProt: Wait " + QString::number(spamFloodProtTime + currentTime.secsTo(mySpamBroadcastFloodTimerStart)) + " secs before new .spam", bestPlayer.name);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-// mySpamBroadcastFloodTimerStart = currentTime;
|
|
|
|
-// mySpamBroadcastFloodTimer->start(spamFloodProtTime*1000);
|
|
|
|
|
|
+ int time;
|
|
|
|
+ if(command == "qw")
|
|
|
|
+ time = Settings::globalInstance()->qwFloodProtTime();
|
|
|
|
+ else
|
|
|
|
+ time = Settings::globalInstance()->spamFloodProtTime();
|
|
|
|
+ myBroadcastFloodTimerStart = currentTime;
|
|
|
|
+ myBroadcastFloodTimer->start(time*1000);
|
|
}
|
|
}
|
|
|
|
|
|
// Prepare all strings to be broadcasted
|
|
// Prepare all strings to be broadcasted
|
|
@@ -463,12 +457,6 @@ void Client::onDownloadStarted(const char *fileName)
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
void Client::run()
|
|
void Client::run()
|
|
{
|
|
{
|
|
- // if(!myJoinMessageTimer->isActive() && !myJoinMessagePrinted)
|
|
|
|
- // {
|
|
|
|
- // say("Hi, I am QWNET's bot, type .help to see my commands.");
|
|
|
|
- // myJoinMessagePrinted = true;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
// Keep nick... Simply set name again after 30 secs
|
|
// Keep nick... Simply set name again after 30 secs
|
|
if(!myKeepNickTimer->isActive())
|
|
if(!myKeepNickTimer->isActive())
|
|
{
|
|
{
|
|
@@ -538,13 +526,11 @@ void Client::setAutoDetectSP(bool autoDetect)
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
void Client::spDetection()
|
|
void Client::spDetection()
|
|
{
|
|
{
|
|
-// scheduleCmd("say s-p", 2000);
|
|
|
|
say("s-p");
|
|
say("s-p");
|
|
mySPDetectionTimer->start(2000);
|
|
mySPDetectionTimer->start(2000);
|
|
}
|
|
}
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
-static QRegExp coloredTextStrings("(\\{&c[0-9a-fA-F]{3}).*?(\\{&c[0-9a-fA-F]{3})|(\\})");
|
|
|
|
QString Client::parseNameFun(const QString &string)
|
|
QString Client::parseNameFun(const QString &string)
|
|
{
|
|
{
|
|
QByteArray b(string.toLatin1());
|
|
QByteArray b(string.toLatin1());
|