Allow filtering without an account

alt-html-css
Bob Mottram 2020-12-19 11:41:40 +00:00
parent cc2b9735fc
commit 97a5b774d4
1 changed files with 8 additions and 5 deletions

View File

@ -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 You can add individual words or use word1+word2 to indicate that two
words must be present although not necessarily adjacent 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 # optionally remove retweets
removeTwitter = baseDir + '/accounts/' + \ removeTwitter = baseDir + '/accounts/' + \
nickname + '@' + domain + '/.removeTwitter' nickname + '@' + domain + '/.removeTwitter'
@ -98,11 +106,6 @@ def isFiltered(baseDir: str, nickname: str, domain: str, content: str) -> bool:
if isTwitterPost(content): if isTwitterPost(content):
return True return True
globalFiltersFilename = baseDir + '/accounts/filters.txt'
if os.path.isfile(globalFiltersFilename):
if content + '\n' in open(globalFiltersFilename).read():
return True
accountFiltersFilename = baseDir + '/accounts/' + \ accountFiltersFilename = baseDir + '/accounts/' + \
nickname + '@' + domain + '/filters.txt' nickname + '@' + domain + '/filters.txt'
if os.path.isfile(accountFiltersFilename): if os.path.isfile(accountFiltersFilename):