From 97a5b774d4ccc8bcd5f3bde3dd52532bbf4975d7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 19 Dec 2020 11:41:40 +0000 Subject: [PATCH] Allow filtering without an account --- filters.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/filters.py b/filters.py index 42db4959..fda11faf 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):