implements #157 - chatbot whitelist
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user