diff --git a/mesh_bot.py b/mesh_bot.py index dfedffd..efa0974 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -421,6 +421,22 @@ async def start_rx(): logger.debug(f"System: Repeater Enabled for Channels: {repeater_channels}") if radio_dectection_enabled: logger.debug(f"System: Radio Detection Enabled using rigctld at {rigControlServerAddress} brodcasting to channels: {sigWatchBrodcastCh} for {get_freq_common_name(get_hamlib('f'))}") + if scheduler_enabled: + # Examples of using the scheduler + # https://schedule.readthedocs.io/en/stable/ + + # Good Morning Every day at 09:00 using send_message function to channel 2 on device 1 + #schedule.every().day.at("09:00").do(send_message, "Good Morning", 2, 0, 1) + + # Send WX every Morning at 08:00 using handle_wxc function to channel 2 on device 1 + #schedule.every().day.at("08:00").do(send_message, handle_wxc(0, 1, 'wx'), 2, 0, 1) + + # Send a Net Starting Now Message Every Wednesday at 19:00 using send_message function to channel 2 on device 1 + #schedule.every().wednesday.at("19:00").do(send_message, "The Radio Net Starting Now!", 2, 0, 1) + + # + logger.debug("System: Starting the broadcast scheduler") + await BroadcastScheduler() # here we go loopty loo while True: diff --git a/modules/settings.py b/modules/settings.py index c456f6e..3a84880 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -24,6 +24,7 @@ max_retry_count1 = 4 # max retry count for interface 1 max_retry_count2 = 4 # max retry count for interface 2 retry_int1 = False retry_int2 = False +scheduler_enabled = False # enable the scheduler currently config via code only # Read the config file, if it does not exist, create basic config file config = configparser.ConfigParser() diff --git a/modules/system.py b/modules/system.py index e5b9001..26bcc46 100644 --- a/modules/system.py +++ b/modules/system.py @@ -64,6 +64,13 @@ if dad_jokes_enabled: trap_list = trap_list + ("joke",) help_message = help_message + ", joke" +# Scheduled Broadcast Configuration +if scheduler_enabled: + import schedule # pip install schedule + # Reminder Scheduler is enabled every day at noon + schedule.every().day.at("12:00").do(logger.info, "Scheduler: Reminder Scheduler is enabled") + +# Sentry Configuration if sentry_enabled: from math import sqrt import geopy.distance # pip install geopy @@ -323,6 +330,7 @@ def get_node_location(number, nodeInt=1, channel=0): else: logger.warning(f"System: No nodes found") return position + return position def get_closest_nodes(nodeInt=1,returnCount=3): node_list = [] @@ -508,6 +516,12 @@ def exit_handler(): asyncLoop.close() exit (0) +async def BroadcastScheduler(): + # handle schedule checks for the broadcast of messages + while True: + schedule.run_pending() + await asyncio.sleep(1) + async def handleSignalWatcher(): global lastHamLibAlert, antiSpam, sigWatchBrodcastCh # monitor rigctld for signal strength and frequency