mirror of
https://github.com/markqvist/lxmf_messageboard.git
synced 2024-10-01 02:25:36 -04:00
Update: announcements, get directory, reduce log output
* Created announce_check function which will check if need to rebroadcast announcement (hard coded to every 30 minutes) * Using os.getcwd now can get current directory so doesn't need hardcoded dir for storage/identity * Reduced RNS.log printout * Adjustable redis database
This commit is contained in:
parent
98aeda263c
commit
c343ac170a
@ -6,10 +6,11 @@ import shortuuid
|
||||
import time
|
||||
|
||||
display_name = "SolarExpress Message Board"
|
||||
configdir = "~/retic/"
|
||||
identitypath = configdir+"storage/identity"
|
||||
configdir = os.getcwd()
|
||||
identitypath = configdir+"/storage/identity"
|
||||
redis_db = 2
|
||||
|
||||
r = redis.Redis(db=2, decode_responses=True)
|
||||
r = redis.Redis(db=redis_db, decode_responses=True)
|
||||
|
||||
def setup_lxmf():
|
||||
|
||||
@ -94,10 +95,18 @@ def send_message(destination_hash, message_content):
|
||||
# Send it
|
||||
message_router.handle_outbound(lxm)
|
||||
|
||||
def announce_check():
|
||||
if r.exists('announce'):
|
||||
RNS.log('Recent announcement', RNS.LOG_DEBUG)
|
||||
else:
|
||||
r.set('announce', 1)
|
||||
r.expire('announce', 1800)
|
||||
announce_now(local_lxmf_destination)
|
||||
RNS.log('Announcement sent, expr set 1800 seconds', RNS.LOG_INFO)
|
||||
|
||||
|
||||
# Start Reticulum and print out all the debug messages
|
||||
reticulum = RNS.Reticulum(loglevel=RNS.LOG_EXTREME)
|
||||
reticulum = RNS.Reticulum(loglevel=RNS.LOG_VERBOSE)
|
||||
|
||||
# Create a Identity.
|
||||
current_identity = setup_lxmf()
|
||||
@ -117,17 +126,11 @@ message_router.register_delivery_callback(lxmf_delivery)
|
||||
# Announce node properties
|
||||
|
||||
RNS.log('LXMF Router ready to receive on: {}'.format(RNS.prettyhexrep(local_lxmf_destination.hash)), RNS.LOG_INFO)
|
||||
|
||||
if r.exists('announce'):
|
||||
RNS.log('Recent announcement', RNS.LOG_INFO)
|
||||
else:
|
||||
r.set('announce', 1)
|
||||
r.expire('announce', 1800)
|
||||
announce_now(local_lxmf_destination)
|
||||
RNS.log('Announcement sent, expr set 1800 seconds', RNS.LOG_INFO)
|
||||
announce_check()
|
||||
|
||||
while True:
|
||||
|
||||
# Work through redis message queue
|
||||
for i in range(0, r.llen('message_queue')):
|
||||
message_id = r.lpop('message_queue')
|
||||
message = r.get(message_id)
|
||||
@ -135,4 +138,9 @@ while True:
|
||||
destination_hash = message_id.split('_')[0]
|
||||
RNS.log('{} {}'.format(destination_hash, message), RNS.LOG_INFO)
|
||||
send_message(destination_hash, message)
|
||||
|
||||
# Check whether we need to make another announcement
|
||||
announce_check()
|
||||
|
||||
#Sleep
|
||||
time.sleep(10)
|
||||
|
Loading…
Reference in New Issue
Block a user