Only match eligible exclude statements and make sure legitimate keywords get through

This commit is contained in:
Mark Veidemanis 2017-11-28 19:19:27 +00:00
parent 6569314267
commit 1b0217e0a6
1 changed files with 14 additions and 4 deletions

View File

@ -306,6 +306,7 @@ class Helper(object):
def isKeyword(self, msg):
message = msg.lower()
messageDuplicate = message
toUndo = False
uniqueNum = 0
totalNum = 0
@ -315,11 +316,19 @@ class Helper(object):
for x in config["KeywordsExcept"][i]:
if x in message:
toUndo = True
messageDuplicate = messageDuplicate.replace(x, "\0\r\n\n\0")
for y in config["Keywords"]:
if i in messageDuplicate:
totalNum += messageDuplicate.count(i)
message = messageDuplicate.replace(i, "{"+i+"}")
message = message.replace("\0\r\n\n\0", x)
uniqueNum += 1
if toUndo == False:
totalNum += message.count(i)
message = message.replace(i, "{"+i+"}")
uniqueNum += 1
if toUndo == False:
totalNum += message.count(i)
message = message.replace(i, "{"+i+"}")
uniqueNum += 1
toUndo = False
if totalNum == 0:
@ -789,6 +798,7 @@ if __name__ == "__main__":
config = helper.getConfig()
pool = helper.getPool()
help = helper.getHelp()
for i in pool.keys():
if pool[i]["enabled"] == True:
helper.addBot(i)