mirror of
https://github.com/markqvist/lxmf_messageboard.git
synced 2025-02-22 07:30:01 -05:00
Added Message Board pruning
* Script will now prune the message board to 'max_messages' to ensure the board doesn't get too long, default set to 20 * adjusted indents to match in all functions
This commit is contained in:
parent
c343ac170a
commit
6b9418a917
@ -9,11 +9,11 @@ display_name = "SolarExpress Message Board"
|
||||
configdir = os.getcwd()
|
||||
identitypath = configdir+"/storage/identity"
|
||||
redis_db = 2
|
||||
max_messages = 20
|
||||
|
||||
r = redis.Redis(db=redis_db, decode_responses=True)
|
||||
|
||||
def setup_lxmf():
|
||||
|
||||
if os.path.isfile(identitypath):
|
||||
identity = RNS.Identity.from_file(identitypath)
|
||||
RNS.log('Loaded identity from file', RNS.LOG_INFO)
|
||||
@ -104,6 +104,9 @@ def announce_check():
|
||||
announce_now(local_lxmf_destination)
|
||||
RNS.log('Announcement sent, expr set 1800 seconds', RNS.LOG_INFO)
|
||||
|
||||
def prune_messageboard(max_messages):
|
||||
RNS.log('Pruning message board', RNS.LOG_DEBUG)
|
||||
r.ltrim('message_board_general', 0, max_messages -1)
|
||||
|
||||
# Start Reticulum and print out all the debug messages
|
||||
reticulum = RNS.Reticulum(loglevel=RNS.LOG_VERBOSE)
|
||||
@ -142,5 +145,8 @@ while True:
|
||||
# Check whether we need to make another announcement
|
||||
announce_check()
|
||||
|
||||
# Keep the message board trim
|
||||
prune_messageboard(max_messages)
|
||||
|
||||
#Sleep
|
||||
time.sleep(10)
|
||||
|
Loading…
x
Reference in New Issue
Block a user