add kick counter list to chatcleaner to kickban disturbing players after multiple kicks for chat offence
This commit is contained in:
@@ -43,7 +43,7 @@ using namespace std;
|
|||||||
CleanerConfig::CleanerConfig()
|
CleanerConfig::CleanerConfig()
|
||||||
{
|
{
|
||||||
// !!!! Revisionsnummer der Configdefaults !!!!!
|
// !!!! Revisionsnummer der Configdefaults !!!!!
|
||||||
configRev = 7;
|
configRev = 8;
|
||||||
|
|
||||||
// Pfad und Dateinamen setzen
|
// Pfad und Dateinamen setzen
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -122,6 +122,9 @@ CleanerConfig::CleanerConfig()
|
|||||||
configList.push_back(ConfigInfo("CapsFloodCapsNumberToTrigger", CONFIG_TYPE_INT, "10"));
|
configList.push_back(ConfigInfo("CapsFloodCapsNumberToTrigger", CONFIG_TYPE_INT, "10"));
|
||||||
configList.push_back(ConfigInfo("LetterRepeatingNumberToTrigger", CONFIG_TYPE_INT, "10"));
|
configList.push_back(ConfigInfo("LetterRepeatingNumberToTrigger", CONFIG_TYPE_INT, "10"));
|
||||||
|
|
||||||
|
configList.push_back(ConfigInfo("KickNumberToBan", CONFIG_TYPE_INT, "2"));
|
||||||
|
configList.push_back(ConfigInfo("SecondsToForgetAboutKick", CONFIG_TYPE_INT, "1800"));
|
||||||
|
|
||||||
list<string> badWordsList;
|
list<string> badWordsList;
|
||||||
badWordsList.push_back("arsch");
|
badWordsList.push_back("arsch");
|
||||||
badWordsList.push_back("asshole");
|
badWordsList.push_back("asshole");
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
enum ActionType {
|
enum ActionType {
|
||||||
NOTHING,
|
NOTHING,
|
||||||
WARN,
|
WARN,
|
||||||
KICK };
|
KICK,
|
||||||
|
KICKBAN
|
||||||
|
};
|
||||||
|
|
||||||
enum OffenceType {
|
enum OffenceType {
|
||||||
NONE,
|
NONE,
|
||||||
@@ -30,6 +32,10 @@ MessageFilter::MessageFilter(CleanerConfig *c): config(c)
|
|||||||
myCapsFloodCheck = new CapsFloodCheck;
|
myCapsFloodCheck = new CapsFloodCheck;
|
||||||
myLetterRepeatingCheck = new LetterRepeatingCheck;
|
myLetterRepeatingCheck = new LetterRepeatingCheck;
|
||||||
myUrlCheck = new UrlCheck;
|
myUrlCheck = new UrlCheck;
|
||||||
|
|
||||||
|
cleanTimer = new QTimer();
|
||||||
|
connect(cleanTimer, SIGNAL(timeout()), this, SLOT(cleanKickCounterList()));
|
||||||
|
cleanTimer->start(30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageFilter::~MessageFilter() {
|
MessageFilter::~MessageFilter() {
|
||||||
@@ -39,6 +45,7 @@ MessageFilter::~MessageFilter() {
|
|||||||
delete myCapsFloodCheck;
|
delete myCapsFloodCheck;
|
||||||
delete myLetterRepeatingCheck;
|
delete myLetterRepeatingCheck;
|
||||||
delete myUrlCheck;
|
delete myUrlCheck;
|
||||||
|
delete cleanTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
||||||
@@ -75,6 +82,27 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
|||||||
//remove playerId from all lists and as LAST from myClientWarnLevelList
|
//remove playerId from all lists and as LAST from myClientWarnLevelList
|
||||||
myTextFloodCheck->removeNickFromList(i.key());
|
myTextFloodCheck->removeNickFromList(i.key());
|
||||||
myClientWarnLevelList.remove(i.key());
|
myClientWarnLevelList.remove(i.key());
|
||||||
|
//check if player is already on kickCounterList
|
||||||
|
QMap<QString, ClientKickInfos>::const_iterator j = myClientKickCounterList.find(nick);
|
||||||
|
if(j == myClientKickCounterList.end()) {
|
||||||
|
//if player is NOT on this list put the playerId on it to ban after multiple offence
|
||||||
|
ClientKickInfos tmpInfos;
|
||||||
|
tmpInfos.kickNumber = 1;
|
||||||
|
tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds();
|
||||||
|
myClientKickCounterList.insert(nick, tmpInfos);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//please is already on the list: either raise kickNumber or kickban when kickNumerToBan is reached
|
||||||
|
if(j.value().kickNumber == kickNumberToBan) {
|
||||||
|
action = KICKBAN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ClientKickInfos tmpInfos;
|
||||||
|
tmpInfos.kickNumber = j.value().kickNumber+1;
|
||||||
|
tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds();
|
||||||
|
myClientKickCounterList.insert(nick, tmpInfos);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ClientWarnInfos tmpInfos;
|
ClientWarnInfos tmpInfos;
|
||||||
@@ -86,10 +114,6 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(action == KICK) {
|
|
||||||
returnMessage = QString("Kick: %1\n").arg(nick);
|
|
||||||
returnAction = QString("kick");
|
|
||||||
}
|
|
||||||
if(action == WARN) {
|
if(action == WARN) {
|
||||||
|
|
||||||
switch(offence) {
|
switch(offence) {
|
||||||
@@ -117,6 +141,14 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
|||||||
}
|
}
|
||||||
returnAction = QString("warn");
|
returnAction = QString("warn");
|
||||||
}
|
}
|
||||||
|
else if(action == KICK) {
|
||||||
|
returnMessage = QString("%1 kicked! Please respect: http://chatrules.pokerth.net\n").arg(nick);
|
||||||
|
returnAction = QString("kick");
|
||||||
|
}
|
||||||
|
else if(action == KICKBAN) {
|
||||||
|
returnMessage = QString("%1 kicked and banned! Please respect: http://chatrules.pokerth.net\n").arg(nick);
|
||||||
|
returnAction = QString("kickban");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
returnAction = QString("");
|
returnAction = QString("");
|
||||||
@@ -131,6 +163,7 @@ void MessageFilter::refreshConfig() {
|
|||||||
|
|
||||||
// global settings
|
// global settings
|
||||||
warnLevelToKick = config->readConfigInt("WarnLevelToKick");
|
warnLevelToKick = config->readConfigInt("WarnLevelToKick");
|
||||||
|
kickNumberToBan = config->readConfigInt("KickNumberToBan");
|
||||||
|
|
||||||
// special check settings
|
// special check settings
|
||||||
//Bad Words
|
//Bad Words
|
||||||
@@ -163,3 +196,15 @@ void MessageFilter::refreshConfig() {
|
|||||||
myLetterRepeatingCheck->setLetterNumberToTrigger(config->readConfigInt("LetterRepeatingNumberToTrigger"));
|
myLetterRepeatingCheck->setLetterNumberToTrigger(config->readConfigInt("LetterRepeatingNumberToTrigger"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageFilter::cleanKickCounterList()
|
||||||
|
{
|
||||||
|
QMapIterator<QString, ClientKickInfos> it(myClientKickCounterList);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
if(timer.elapsed().total_seconds()-it.value().lastKickTimestamp > config->readConfigInt("SecondsToForgetAboutKick")) {
|
||||||
|
qDebug() << it.key() << "removed from kick counter list" << endl;
|
||||||
|
myClientKickCounterList.remove(it.key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <third_party/boost/timers.hpp>
|
||||||
|
|
||||||
class BadWordCheck;
|
class BadWordCheck;
|
||||||
class TextFloodCheck;
|
class TextFloodCheck;
|
||||||
@@ -19,6 +20,7 @@ public:
|
|||||||
|
|
||||||
QStringList check(unsigned, QString, QString);
|
QStringList check(unsigned, QString, QString);
|
||||||
void refreshConfig();
|
void refreshConfig();
|
||||||
|
void cleanKickCounterList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BadWordCheck *myBadWordCheck;
|
BadWordCheck *myBadWordCheck;
|
||||||
@@ -33,11 +35,21 @@ private:
|
|||||||
int warnLevel;
|
int warnLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ClientKickInfos {
|
||||||
|
size_t lastKickTimestamp;
|
||||||
|
int kickNumber;
|
||||||
|
};
|
||||||
|
|
||||||
QMap<unsigned, ClientWarnInfos> myClientWarnLevelList;
|
QMap<unsigned, ClientWarnInfos> myClientWarnLevelList;
|
||||||
|
QMap<QString, ClientKickInfos> myClientKickCounterList;
|
||||||
|
|
||||||
int warnLevelToKick;
|
int warnLevelToKick;
|
||||||
|
int kickNumberToBan;
|
||||||
|
|
||||||
CleanerConfig *config;
|
CleanerConfig *config;
|
||||||
|
|
||||||
|
boost::timers::portable::second_timer timer;
|
||||||
|
QTimer *cleanTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGEFILTER_H
|
#endif // MESSAGEFILTER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user