implements #157 - chatbot whitelist

This commit is contained in:
doitux
2012-12-09 19:44:20 +01:00
parent a3fe2c330d
commit a6420642f3
4 changed files with 37 additions and 4 deletions
+18 -3
View File
@@ -9,11 +9,26 @@ BadWordCheck::BadWordCheck()
bool BadWordCheck::run(QString msg)
{
msg = msg.toLower();
bool badMessage(false);
QStringListIterator it(badWords);
while (it.hasNext()) {
if(msg.contains(it.next()))
return true;
QString bw=it.next();
if(msg.contains(bw)) {
badMessage=true;
//exception check
QStringListIterator it2(badWordsException);
while (it2.hasNext()) {
QString bwe=it2.hasNext();
if(bwe.contains(bw) && msg.contains(bwe)) {
badMessage=false;
}
}
}
}
return false;
if(badMessage) return true;
else return false;
}