From eb80a7ea43ce249f8b7b8a381b9e4ff4cbccc0c1 Mon Sep 17 00:00:00 2001 From: Mason10198 <31994327+Mason10198@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:08:41 -0500 Subject: [PATCH] More customizable Blocking Start work to add function-specific blocking in addition to global blocking --- SkywarnPlus.py | 17 ++++++++++++----- config.ini | 13 ++++++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/SkywarnPlus.py b/SkywarnPlus.py index 3af586a..e5ccc05 100644 --- a/SkywarnPlus.py +++ b/SkywarnPlus.py @@ -55,7 +55,9 @@ if not os.path.exists(tmp_dir): os.makedirs(tmp_dir) # List of blocked events -blocked_events = config["Blocking"].get("BlockedEvents").split(",") +global_blocked_events = config["Blocking"].get("GlobalBlockedEvents").split(",") +sayalert_blocked_events = config["Blocking"].get("SayAlertBlockedEvents").split(",") +tailmessage_blocked_events = config["Blocking"].get("TailmessageBlockedEvents").split(",") # Configuration for tailmessage tailmessage_config = config["Tailmessage"] # Flag to enable/disable tailmessage @@ -252,7 +254,7 @@ logger.debug("Base directory: {}".format(baseDir)) logger.debug("Temporary directory: {}".format(tmp_dir)) logger.debug("Sounds path: {}".format(sounds_path)) logger.debug("Tailmessage path: {}".format(tailmessage_file)) -logger.debug("Blocked events: {}".format(blocked_events)) +logger.debug("Global Blocked events: {}".format(global_blocked_events)) def getAlerts(countyCodes): @@ -292,10 +294,10 @@ def getAlerts(countyCodes): expires_time = parser.isoparse(expires) if expires_time > current_time: event = feature["properties"]["event"] - for blocked_event in blocked_events: - if fnmatch.fnmatch(event, blocked_event): + for global_blocked_event in global_blocked_events: + if fnmatch.fnmatch(event, global_blocked_event): logger.debug( - "Blocking {} as per configuration".format(event) + "Globally Blocking {} as per configuration".format(event) ) break else: @@ -329,6 +331,11 @@ def sayAlert(alerts): ) for alert in alerts: + # Check if alert is in the SayAlertBlockedEvents list + if alert in sayalert_blocked_events: + logger.debug("Alert blocked by SayAlertBlockedEvents: {}".format(alert)) + continue + try: index = WS.index(alert) audio_file = AudioSegment.from_wav( diff --git a/config.ini b/config.ini index ba05dbf..88c6d3b 100644 --- a/config.ini +++ b/config.ini @@ -35,8 +35,19 @@ SayAllClear = True ; Blocking settings [Blocking] +; GLOBAL BLOCKING - These alerts will be completely ignored and filtered out of the entire SkywarnPlus workflow ; CASE SENSITIVE list of events to ignore, comma separated. Wildcards can be used, e.g. *Statement, *Advisory -BlockedEvents = +GlobalBlockedEvents = + +; SayAlert Blocking +; These alerts will be blocked from being spoken when they are received +; These alerts will still be added to the tailmessage +SayAlertBlockedEvents = + +; Tailmessage Blocking +; These alerts will be blocked from being added to the tailmessage +; These alerts will still be spoken when they are received +TailmessageBlockedEvents = ; Tail message settings [Tailmessage]