diff --git a/filters.py b/filters.py index 42db49591..fda11fafc 100644 --- a/filters.py +++ b/filters.py @@ -91,6 +91,14 @@ def isFiltered(baseDir: str, nickname: str, domain: str, content: str) -> bool: You can add individual words or use word1+word2 to indicate that two words must be present although not necessarily adjacent """ + globalFiltersFilename = baseDir + '/accounts/filters.txt' + if os.path.isfile(globalFiltersFilename): + if content + '\n' in open(globalFiltersFilename).read(): + return True + + if not nickname or not domain: + return False + # optionally remove retweets removeTwitter = baseDir + '/accounts/' + \ nickname + '@' + domain + '/.removeTwitter' @@ -98,11 +106,6 @@ def isFiltered(baseDir: str, nickname: str, domain: str, content: str) -> bool: if isTwitterPost(content): return True - globalFiltersFilename = baseDir + '/accounts/filters.txt' - if os.path.isfile(globalFiltersFilename): - if content + '\n' in open(globalFiltersFilename).read(): - return True - accountFiltersFilename = baseDir + '/accounts/' + \ nickname + '@' + domain + '/filters.txt' if os.path.isfile(accountFiltersFilename):