mirror of https://gitlab.com/bashrc2/epicyon
Load cw lists at startup
parent
13d1224b35
commit
b8c957eb38
22
blocking.py
22
blocking.py
|
@ -874,3 +874,25 @@ def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool:
|
|||
print('Broch mode has elapsed')
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def loadLists(baseDir: str, verbose: bool) -> {}:
|
||||
"""Load lists used for blocking or warnings
|
||||
"""
|
||||
if not os.path.isdir(baseDir + '/lists'):
|
||||
return {}
|
||||
result = {}
|
||||
for subdir, dirs, files in os.walk(baseDir + '/lists'):
|
||||
for f in files:
|
||||
if not f.endswith('.json'):
|
||||
continue
|
||||
listFilename = os.path.join(baseDir + '/lists', f)
|
||||
listJson = loadJson(listFilename)
|
||||
if not listJson:
|
||||
continue
|
||||
if listJson.get('name') and listJson.get('domains'):
|
||||
name = listJson['name']
|
||||
if verbose:
|
||||
print('List: ' + name)
|
||||
result[name] = listJson
|
||||
return result
|
||||
|
|
|
@ -125,6 +125,7 @@ from media import replaceTwitter
|
|||
from media import attachMedia
|
||||
from media import pathIsVideo
|
||||
from media import pathIsAudio
|
||||
from blocking import loadLists
|
||||
from blocking import updateBlockedCache
|
||||
from blocking import mutePost
|
||||
from blocking import unmutePost
|
||||
|
@ -17164,6 +17165,7 @@ def runDaemon(defaultReplyIntervalHours: int,
|
|||
updateBlockedCache(baseDir, httpd.blockedCache,
|
||||
httpd.blockedCacheLastUpdated,
|
||||
httpd.blockedCacheUpdateSecs)
|
||||
httpd.lists = loadLists(baseDir, True)
|
||||
|
||||
# cache to store css files
|
||||
httpd.cssCache = {}
|
||||
|
|
Loading…
Reference in New Issue