From c7051f191fe93e0627e623c0ae7d906f3401f48b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 19 Dec 2020 13:00:35 +0000 Subject: [PATCH] Improve global filtering --- filters.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/filters.py b/filters.py index fda11fafc..4ae1fcede 100644 --- a/filters.py +++ b/filters.py @@ -93,8 +93,12 @@ def isFiltered(baseDir: str, nickname: str, domain: str, content: str) -> bool: """ globalFiltersFilename = baseDir + '/accounts/filters.txt' if os.path.isfile(globalFiltersFilename): - if content + '\n' in open(globalFiltersFilename).read(): - return True + wordsFile = open(globalFiltersFilename, 'r') + if wordsFile: + wordsList = wordsFile.read().split('\n') + for word in wordsList: + if word in content: + return True if not nickname or not domain: return False