chatcleaner: inital url spam check. configurable url string list and
exceptions list for urls like pokerth.net ;-)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "cleanerconfig.h"
|
||||
#include "capsfloodcheck.h"
|
||||
#include "letterrepeatingcheck.h"
|
||||
#include "urlcheck.h"
|
||||
|
||||
enum ActionType {
|
||||
NOTHING,
|
||||
@@ -17,7 +18,8 @@ enum OffenceType {
|
||||
BAD_WORD,
|
||||
TEXT_FLOOD_LINES,
|
||||
CAPS_FLOOD,
|
||||
LETTER_REPEATING
|
||||
LETTER_REPEATING,
|
||||
URL
|
||||
};
|
||||
|
||||
MessageFilter::MessageFilter(CleanerConfig *c): config(c)
|
||||
@@ -26,6 +28,7 @@ MessageFilter::MessageFilter(CleanerConfig *c): config(c)
|
||||
myTextFloodCheck = new TextFloodCheck;
|
||||
myCapsFloodCheck = new CapsFloodCheck;
|
||||
myLetterRepeatingCheck = new LetterRepeatingCheck;
|
||||
myUrlCheck = new UrlCheck;
|
||||
}
|
||||
|
||||
QString MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
||||
@@ -38,6 +41,7 @@ QString MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
||||
if(myBadWordCheck->run(msg)) offence = BAD_WORD;
|
||||
if(myCapsFloodCheck->run(msg)) offence = CAPS_FLOOD;
|
||||
if(myLetterRepeatingCheck->run(msg)) offence = LETTER_REPEATING;
|
||||
if(myUrlCheck->run(msg)) offence = URL;
|
||||
if(myTextFloodCheck->run(playerId)) offence = TEXT_FLOOD_LINES;
|
||||
|
||||
if(offence){
|
||||
@@ -90,6 +94,10 @@ QString MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
||||
returnMessage = QString ("<PokerTHCleaner> %1: Warning: You've triggered letter repeating protection, stop repeating!\n").arg(nick);
|
||||
}
|
||||
break;
|
||||
case URL: {
|
||||
returnMessage = QString ("<PokerTHCleaner> %1: Warning: You've triggered url spam protection, stop posting urls!\n").arg(nick);
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
@@ -115,6 +123,22 @@ void MessageFilter::refreshConfig() {
|
||||
}
|
||||
myBadWordCheck->setBadWords(bwList);
|
||||
|
||||
std::list<std::string> urlStringsList = config->readConfigStringList("UrlStringsList");
|
||||
std::list<std::string>::iterator it2;
|
||||
QStringList urlList;
|
||||
for(it2= urlStringsList.begin(); it2 != urlStringsList.end(); it2++) {
|
||||
urlList << QString::fromUtf8(it2->c_str());
|
||||
}
|
||||
myUrlCheck->setUrlStrings(urlList);
|
||||
|
||||
std::list<std::string> urlExceptionStringsList = config->readConfigStringList("UrlExceptionStringsList");
|
||||
std::list<std::string>::iterator it3;
|
||||
QStringList urlExceptionList;
|
||||
for(it3= urlExceptionStringsList.begin(); it3 != urlExceptionStringsList.end(); it3++) {
|
||||
urlExceptionList << QString::fromUtf8(it3->c_str());
|
||||
}
|
||||
myUrlCheck->setUrlExceptionStrings(urlExceptionList);
|
||||
|
||||
myTextFloodCheck->setTextFloodLevelToTrigger(config->readConfigInt("TextFloodLevelToTrigger"));
|
||||
myCapsFloodCheck->setCapsNumberToTrigger(config->readConfigInt("CapsFloodCapsNumberToTrigger"));
|
||||
myLetterRepeatingCheck->setLetterNumberToTrigger(config->readConfigInt("LetterRepeatingNumberToTrigger"));
|
||||
|
||||
Reference in New Issue
Block a user