Use regex for alert content smart filter
[weather.git] / weather.py
index 6b42a84..62f73da 100644 (file)
@@ -336,10 +336,11 @@ def get_alert(
     if alert:
         if verbose: return alert
         else:
-            if alert.find("\nNATIONAL WEATHER SERVICE") == -1:
-                muted = False
-            else:
+            import re
+            if re.search(r"\nNational Weather Service", alert):
                 muted = True
+            else:
+                muted = False
             lines = alert.split("\n")
             import time
             # TODO: make this offset configurable
@@ -360,7 +361,7 @@ def get_alert(
                 if line.startswith("Expires:") \
                     and "Expires:" + valid_time > line:
                     return ""
-                if muted and line.startswith("NATIONAL WEATHER SERVICE"):
+                if muted and line.startswith("National Weather Service"):
                     muted = False
                     line = ""
                 elif line == "&&":