From c27b6ed8a1e86c4096ee511f6877499dfcab69b5 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 16:18:38 -0800 Subject: [PATCH 01/13] enhanceEmergency Alerting --- README.md | 16 ++++++------ config.template | 13 +++++----- mesh_bot.py | 8 +++--- modules/settings.py | 27 ++++++++------------ modules/system.py | 61 ++++++++++++++++++++++++++++++++++----------- 5 files changed, 75 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 5695fdb..7ca40a5 100644 --- a/README.md +++ b/README.md @@ -213,19 +213,17 @@ alert_interface = 1 ### EAS Alerting To Alert on Mesh with the EAS API you can set the channels and enable, checks every 20min. -#### FEMA iPAWS/EAS -This uses the SAME, FIPS, ZIP code to locate the alerts in the feed. By default ignoring Test messages. femaAlertBroadcastCh is currently not written, still under development. +#### FEMA iPAWS/EAS and UK.gov +This uses USA: SAME, FIPS, ZIP code to locate the alerts in the feed. By default ignoring Test messages. UK.gov for England ```ini -# FEMA IPAWS/CAP Alert Broadcast -femaAlertBroadcastEnabled = True -# FEMA IPAWS/CAP Alert Broadcast Channels -femaAlertBroadcastCh = 2,4 -# Ignore any headline that includes the word Test -ignoreFEMAtest = True -# comma separated list of codes trigger local alert. (e.g., SAME, FIPS, ZIP) +eAlertBroadcastEnabled = False # Goverment IPAWS/CAP Alert Broadcast +eAlertBroadcastCh = 2,3 # Goverment Emergency IPAWS/CAP Alert Broadcast Channels +ignoreFEMAtest = True # Ignore any headline that includes the word Test +# comma separated list of codes (e.g., SAME,FIPS,ZIP) trigger local alert. # find your SAME https://www.weather.gov/nwr/counties mySAME = 053029,053073 +enableGBalerts = False # use UK.gov for alert source ``` #### NOAA EAS diff --git a/config.template b/config.template index cd56976..7fad863 100644 --- a/config.template +++ b/config.template @@ -127,10 +127,8 @@ NOAAalertCount = 2 # use Open-Meteo API for weather data not NOAA useful for non US locations UseMeteoWxAPI = False -enableGBalerts = False -# NOAA Hydrology -# unique identifiers, LID or USGS ID +# NOAA Hydrology unique identifiers, LID or USGS ID riverListDefault = # EAS Alert Broadcast @@ -138,15 +136,16 @@ wxAlertBroadcastEnabled = False # EAS Alert Broadcast Channels wxAlertBroadcastCh = 2 -# FEMA IPAWS/CAP Alert Broadcast -femaAlertBroadcastEnabled = False -# FEMA IPAWS/CAP Alert Broadcast Channels -femaAlertBroadcastCh = 2 +# Goverment IPAWS/CAP Alert Broadcast +eAlertBroadcastEnabled = False +# Goverment Emergency IPAWS/CAP Alert Broadcast Channels +eAlertBroadcastCh = 2 # Ignore any headline that includes the word Test ignoreFEMAtest = True # comma separated list of codes (e.g., SAME,FIPS,ZIP) trigger local alert. # find your SAME https://www.weather.gov/nwr/counties mySAME = 053029,053073 +enableGBalerts = False # Satalite Pass Prediction # Register for free API https://www.n2yo.com/login/ diff --git a/mesh_bot.py b/mesh_bot.py index 600cc6a..da2519f 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -43,8 +43,8 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n "cqcq": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "cqcqcq": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "dopewars": lambda: handleDopeWars(message, message_from_id, deviceID), - "ea": lambda: handle_fema_alerts(message, message_from_id, deviceID), - "ealert": lambda: handle_fema_alerts(message, message_from_id, deviceID), + "ea": lambda: handle_emergency_alerts(message, message_from_id, deviceID), + "ealert": lambda: handle_emergency_alerts(message, message_from_id, deviceID), "email:": lambda: handle_email(message_from_id, message), "games": lambda: gamesCmdList, "globalthermonuclearwar": lambda: handle_gTnW(), @@ -686,7 +686,7 @@ def handle_wxc(message_from_id, deviceID, cmd): weather = get_NOAAweather(str(location[0]), str(location[1])) return weather -def handle_fema_alerts(message, message_from_id, deviceID): +def handle_emergency_alerts(message, message_from_id, deviceID): location = get_node_location(message_from_id, deviceID) if enableGBalerts: # UK Alerts @@ -1278,6 +1278,8 @@ async def start_rx(): logger.debug(f"System: File Monitor News Reader Enabled for {news_file_path}") if wxAlertBroadcastEnabled: logger.debug(f"System: Weather Alert Broadcast Enabled on channels {wxAlertBroadcastChannel}") + if emergencyAlertBrodcastEnabled: + logger.debug(f"System: Emergency Alert Broadcast Enabled on channels {emergencyAlertBroadcastCh}") if emergency_responder_enabled: logger.debug(f"System: Emergency Responder Enabled on channels {emergency_responder_alert_channel} for interface {emergency_responder_alert_interface}") if enableSMTP: diff --git a/modules/settings.py b/modules/settings.py index 3589592..5c51255 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -155,28 +155,23 @@ latitudeValue = config['location'].getfloat('lat', 48.50) longitudeValue = config['location'].getfloat('lon', -123.0) use_meteo_wxApi = config['location'].getboolean('UseMeteoWxAPI', False) # default False use NOAA - enableGBalerts = config['location'].getboolean('enableGBalerts', False) # default False use_metric = config['location'].getboolean('useMetric', False) # default Imperial units - forecastDuration = config['location'].getint('NOAAforecastDuration', 4) # NOAA forcast days - numWxAlerts = config['location'].getint('NOAAalertCount', 2) # default 2 alerts - wxAlertsEnabled = config['location'].getboolean('NOAAalertsEnabled', True) # default True not enabled yet repeater_lookup = config['location'].get('repeaterLookup', 'rbook') # default repeater lookup source - mySAME = config['location'].get('mySAME', '').split(',') # default empty - ipawsPIN = config['location'].get('ipawsPIN', '000000') # default 000000 - femaAlertBroadcastEnabled = config['location'].getboolean('femaAlertBroadcastEnabled', False) # default False - femaAlertBroadcastCh = config['location'].get('femaAlertBroadcastCh', '2').split(',') # default Channel 2 - wxAlertBroadcastEnabled = config['location'].getboolean('wxAlertBroadcastEnabled', False) # default False - ignoreFEMAtest = config['location'].getboolean('ignoreFEMAtest', True) # default True n2yoAPIKey = config['location'].get('n2yoAPIKey', '') # default empty satListConfig = config['location'].get('satList', '25544').split(',') # default 25544 ISS riverListDefault = config['location'].get('riverList', '').split(',') # default 12061500 Skagit River - # brodcast channel for weather alerts + # location alerts + emergencyAlertBrodcastEnabled = config['location'].getboolean('eAlertBroadcastEnabled', False) # default False + wxAlertBroadcastEnabled = config['location'].getboolean('wxAlertBroadcastEnabled', False) # default False + enableGBalerts = config['location'].getboolean('enableGBalerts', False) # default False + wxAlertsEnabled = config['location'].getboolean('NOAAalertsEnabled', True) # default True + mySAME = config['location'].get('mySAME', '').split(',') # default empty + forecastDuration = config['location'].getint('NOAAforecastDuration', 4) # NOAA forcast days + numWxAlerts = config['location'].getint('NOAAalertCount', 2) # default 2 alerts + ipawsPIN = config['location'].get('ipawsPIN', '000000') # default 000000 + ignoreFEMAtest = config['location'].getboolean('ignoreFEMAtest', True) # default True wxAlertBroadcastChannel = config['location'].get('wxAlertBroadcastCh') - if wxAlertBroadcastChannel: - if ',' in wxAlertBroadcastChannel: - wxAlertBroadcastChannel = config['location'].get('wxAlertBroadcastCh').split(',') - else: - wxAlertBroadcastChannel = config['location'].getint('wxAlertBroadcastCh', 2) # default 2 + emergencyAlertBroadcastCh = config['location'].get('eAlertBroadcastCh', '2').split(',') # default Channel 2 # bbs bbs_enabled = config['bbs'].getboolean('enabled', False) diff --git a/modules/system.py b/modules/system.py index 48c4fb0..ba4c4b1 100644 --- a/modules/system.py +++ b/modules/system.py @@ -665,7 +665,7 @@ def handleMultiPing(nodeID=0, deviceID=1): break -def handleWxBroadcast(deviceID=1): +def handleAlertBroadcast(deviceID=1): # only allow API call every 20 minutes # the watchdog will call this function 3 times, seeing possible throttling on the API clock = datetime.now() @@ -675,15 +675,42 @@ def handleWxBroadcast(deviceID=1): return False # check for alerts - alert = alertBrodcastNOAA() - if alert: - msg = f"🚨 {alert[1]} EAS ALERTs: {alert[0]}" - if isinstance(wxAlertBroadcastChannel, list): - for channel in wxAlertBroadcastChannel: - send_message(msg, int(channel), 0, deviceID) - else: - send_message(msg, wxAlertBroadcastChannel, 0, deviceID) - return True + alertWx = alertBrodcastNOAA() + alertFema = getIpawsAlert(latitudeValue,longitudeValue, shortAlerts=True) + alertUk = get_govUK_alerts(latitudeValue, longitudeValue) + + # format alert + wxAlert = f"🚨 {alertWx[1]} EAS WX ALERT: {alertWx[0]}" + femaAlert = alertFema + ukAlert = alertUk + + if emergencyAlertBrodcastEnabled: + if NO_ALERTS not in femaAlert: + if isinstance(emergencyAlertBroadcastCh, list): + for channel in emergencyAlertBroadcastCh: + send_message(femaAlert, int(channel), 0, deviceID) + else: + send_message(femaAlert, emergencyAlertBroadcastCh, 0, deviceID) + return True + if NO_ALERTS not in ukAlert: + if isinstance(emergencyAlertBroadcastCh, list): + for channel in emergencyAlertBroadcastCh: + send_message(ukAlert, int(channel), 0, deviceID) + else: + send_message(ukAlert, emergencyAlertBroadcastCh, 0, deviceID) + return True + + # pause for 10 seconds + time.sleep(10) + + if wxAlertBroadcastEnabled: + if wxAlert: + if isinstance(wxAlertBroadcastChannel, list): + for channel in wxAlertBroadcastChannel: + send_message(wxAlert, int(channel), 0, deviceID) + else: + send_message(wxAlert, wxAlertBroadcastChannel, 0, deviceID) + return True def onDisconnect(interface): global retry_int1, retry_int2 @@ -1090,8 +1117,10 @@ async def watchdog(): # multiPing handler handleMultiPing(0,1) - if wxAlertBroadcastEnabled: - handleWxBroadcast(1) + # Alert Broadcast + if wxAlertBroadcastEnabled or emergencyAlertBrodcastEnabled: + # weather alerts + handleAlertBroadcast(1) # Telemetry data int1Data = displayNodeTelemetry(0, 1) @@ -1120,10 +1149,12 @@ async def watchdog(): await handleSentinel(2) # multiPing handler - handleMultiPing(0,2) + handleMultiPing(0,1) - if wxAlertBroadcastEnabled: - handleWxBroadcast(2) + # Alert Broadcast + if wxAlertBroadcastEnabled or emergencyAlertBrodcastEnabled: + # weather alerts + handleAlertBroadcast(1) # Telemetry data int2Data = displayNodeTelemetry(0, 2) From 7e5626cd30a118d6d90db0181ebac710ae27e04c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 16:27:09 -0800 Subject: [PATCH 02/13] Update system.py --- modules/system.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/system.py b/modules/system.py index ba4c4b1..b2e22cd 100644 --- a/modules/system.py +++ b/modules/system.py @@ -677,7 +677,11 @@ def handleAlertBroadcast(deviceID=1): # check for alerts alertWx = alertBrodcastNOAA() alertFema = getIpawsAlert(latitudeValue,longitudeValue, shortAlerts=True) - alertUk = get_govUK_alerts(latitudeValue, longitudeValue) + + if enableGBalerts: + alertUk = get_govUK_alerts() + else: + alertUk = NO_ALERTS # format alert wxAlert = f"🚨 {alertWx[1]} EAS WX ALERT: {alertWx[0]}" From 19700f54c5eb249ed000fd261418db8ff8a5a65f Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 16:55:26 -0800 Subject: [PATCH 03/13] Update system.py --- modules/system.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/system.py b/modules/system.py index b2e22cd..ee52d0b 100644 --- a/modules/system.py +++ b/modules/system.py @@ -684,7 +684,9 @@ def handleAlertBroadcast(deviceID=1): alertUk = NO_ALERTS # format alert - wxAlert = f"🚨 {alertWx[1]} EAS WX ALERT: {alertWx[0]}" + if wxAlert: + wxAlert = f"🚨 {alertWx[1]} EAS WX ALERT: {alertWx[0]}" + femaAlert = alertFema ukAlert = alertUk From ac5aa1a201873cda53c709e9fe7195259148d484 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 17:03:53 -0800 Subject: [PATCH 04/13] Update system.py --- modules/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/system.py b/modules/system.py index ee52d0b..1fab557 100644 --- a/modules/system.py +++ b/modules/system.py @@ -684,9 +684,9 @@ def handleAlertBroadcast(deviceID=1): alertUk = NO_ALERTS # format alert - if wxAlert: + if alertWx: wxAlert = f"🚨 {alertWx[1]} EAS WX ALERT: {alertWx[0]}" - + femaAlert = alertFema ukAlert = alertUk From 550b50f74e4c0f0d8f46569c2f496a6198edbd4b Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 17:06:24 -0800 Subject: [PATCH 05/13] Update settings.py --- modules/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/settings.py b/modules/settings.py index 5c51255..fd43147 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -170,7 +170,7 @@ numWxAlerts = config['location'].getint('NOAAalertCount', 2) # default 2 alerts ipawsPIN = config['location'].get('ipawsPIN', '000000') # default 000000 ignoreFEMAtest = config['location'].getboolean('ignoreFEMAtest', True) # default True - wxAlertBroadcastChannel = config['location'].get('wxAlertBroadcastCh') + wxAlertBroadcastChannel = config['location'].get('wxAlertBroadcastCh', '2').split(',') # default Channel 2 emergencyAlertBroadcastCh = config['location'].get('eAlertBroadcastCh', '2').split(',') # default Channel 2 # bbs From e26e876ccf594b66f47511186b33bb10995e14e8 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 17:21:33 -0800 Subject: [PATCH 06/13] Update system.py --- modules/system.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/system.py b/modules/system.py index 1fab557..7ed6425 100644 --- a/modules/system.py +++ b/modules/system.py @@ -686,6 +686,8 @@ def handleAlertBroadcast(deviceID=1): # format alert if alertWx: wxAlert = f"🚨 {alertWx[1]} EAS WX ALERT: {alertWx[0]}" + else: + wxAlert = False femaAlert = alertFema ukAlert = alertUk From 13cb1e8df915cac65b25467fe5e52131bbbbad45 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 17:39:15 -0800 Subject: [PATCH 07/13] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index da2519f..233b5fe 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -23,7 +23,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n message_lower = message.lower() bot_response = "🤖I'm sorry, I'm afraid I can't do that." - # Command List + # Command List processes system.trap_list. system.messageTrap() sends any commands to here default_commands = { "ack": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "ask:": lambda: handle_llm(message_from_id, channel_number, deviceID, message, publicChannel), From 62961506772926de9ed7be095926cad2653edba4 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 17:40:10 -0800 Subject: [PATCH 08/13] Update pong_bot.py --- pong_bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pong_bot.py b/pong_bot.py index 03b705d..aa84355 100755 --- a/pong_bot.py +++ b/pong_bot.py @@ -17,6 +17,7 @@ def auto_response(message, snr, rssi, hop, pkiStatus, message_from_id, channel_n bot_response = "I'm sorry, I'm afraid I can't do that." command_handler = { + # Command List processes system.trap_list. system.messageTrap() sends any commands to here "ack": lambda: handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, channel_number), "cmd": lambda: help_message, "cmd?": lambda: help_message, From 98cbf5528cd2604821e8a182617a1b451b17301f Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 17:46:26 -0800 Subject: [PATCH 09/13] fixEmbedded --- install.sh | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index ac364d9..0116691 100755 --- a/install.sh +++ b/install.sh @@ -11,9 +11,23 @@ printf "\nThis script will try and install the Meshing Around Bot and its depend printf "Installer works best in raspian/debian/ubuntu, if there is a problem, try running the installer again.\n" printf "\nChecking for dependencies...\n" -# check if running on femtofox embedded -if [ $(hostname) == "femtofox" ]; then - printf "\nDetected femtofox embedded skipping dependency installation\n" +# check if running on embedded +printf "\nAre You installing into an embedded system? (y/n)" +read embedded + +if [ $embedded == "y" ]; then + printf "\nDetected embedded skipping dependency installation\n" + if [ $program_path != "/opt/meshing-around" ]; then + printf "\nIt is suggested to project path to /opt/meshing-around\n" + printf "Do you want to move the project to /opt/meshing-around? (y/n)" + read move + if [ $move == "y" ]; then + sudo mv $program_path /opt/meshing-around + cd /opt/meshing-around + printf "\nProject moved to /opt/meshing-around. re-run the installer\n" + exit 0 + fi + fi else # Check and install dependencies if ! command -v python3 &> /dev/null @@ -61,9 +75,9 @@ fi cp config.template config.ini printf "\nConfig files generated!\n" -# check if running on femtofox embedded -if [ $(hostname) == "femtofox" ]; then - printf "\nDetected femtofox embedded skipping venv\n" +# check if running on embedded +if [ $embedded == "y" ]; then + printf "\nDetected embedded skipping venv\n" else printf "\nDo you want to install the bot in a python virtual environment? (y/n)" read venv @@ -144,19 +158,25 @@ sudo systemctl daemon-reload printf "\n service files updated\n" if [ $bot == "pong" ]; then + echo "useradd -M meshbot" + echo "usermod -L meshbot" + echo "Added user meshbot with no home directory" # install service for pong bot sudo cp etc/pong_bot.service /etc/systemd/system/ sudo systemctl enable pong_bot.service fi if [ $bot == "mesh" ]; then + echo "useradd -M meshbot" + echo "usermod -L meshbot" + echo "Added user meshbot with no home directory" # install service for mesh bot sudo cp etc/mesh_bot.service /etc/systemd/system/ sudo systemctl enable mesh_bot.service fi -# check if running on femtofox embedded -if [ $(hostname) != "femtofox" ]; then +# check if running on embedded +if [ $embedded == "n" ]; then # ask if emoji font should be installed for linux printf "\nDo you want to install the emoji font for debian/ubuntu linux? (y/n)" read emoji @@ -195,15 +215,14 @@ if [ $(hostname) != "femtofox" ]; then sudo reboot fi else - # we are on femtofox embedded + # we are on embedded # replace "type = serial" with "type = tcp" in config.ini replace="s|type = serial|type = tcp|g" sed -i "$replace" config.ini # replace "# hostname = 192.168.0.1" with "hostname = localhost" in config.ini replace="s|# hostname = 192.168.0.1|hostname = localhost|g" sed -i "$replace" config.ini - printf "\nConfig file updated for femtofox embedded\n" - + printf "\nConfig file updated for embedded\n" fi printf "\nInstallation complete!\n" From 8ac9c53f1a1a39b0017299bbbd9762ca3f9d858b Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 19 Dec 2024 18:29:35 -0800 Subject: [PATCH 10/13] enhance groupPing --- mesh_bot.py | 2 +- pong_bot.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 233b5fe..1f040f1 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -211,7 +211,7 @@ def handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, chann # if not a DM add the username to the beginning of msg if not useDMForResponse and not isDM: - msg = "@" + get_name_from_number(message_from_id) + msg + msg = "@" + get_name_from_number(message_from_id, 'short', deviceID) + " " + msg return msg diff --git a/pong_bot.py b/pong_bot.py index aa84355..5e03fd3 100755 --- a/pong_bot.py +++ b/pong_bot.py @@ -130,7 +130,7 @@ def handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, chann # if not a DM add the username to the beginning of msg if not useDMForResponse and not isDM: - msg = "@" + get_name_from_number(message_from_id) + msg + msg = "@" + get_name_from_number(message_from_id, 'short', deviceID) + " " + msg return msg From 8f758229cbe55c02cf8558d79af14cebef892e6a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 20 Dec 2024 00:38:59 -0800 Subject: [PATCH 11/13] Update install.sh --- install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install.sh b/install.sh index 0116691..4a73ebd 100755 --- a/install.sh +++ b/install.sh @@ -223,6 +223,10 @@ else replace="s|# hostname = 192.168.0.1|hostname = localhost|g" sed -i "$replace" config.ini printf "\nConfig file updated for embedded\n" + + # Set up the meshing around service + #sudo cp /opt/meshing-around/meshing-around.service /etc/systemd/system/meshing-around.service + #sudo systemctl enable meshing-around.service fi printf "\nInstallation complete!\n" From 9c5c2080cf497ab0e107457935042ede08f5c242 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 20 Dec 2024 01:17:47 -0800 Subject: [PATCH 12/13] Update locationdata_eu.py --- modules/locationdata_eu.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/locationdata_eu.py b/modules/locationdata_eu.py index e460fe0..75f74f3 100644 --- a/modules/locationdata_eu.py +++ b/modules/locationdata_eu.py @@ -11,7 +11,7 @@ trap_list_location_eu = ("ukalert", "ukwx", "ukflood") -def get_govUK_alerts(): +def get_govUK_alerts(shortAlerts=False): try: # get UK.gov alerts url = 'https://www.gov.uk/alerts' @@ -28,10 +28,30 @@ def get_govUK_alerts(): else: return NO_ALERTS + def get_wxUKgov(): # get UK weather warnings url = 'https://www.metoffice.gov.uk/weather/guides/rss' - return NO_ALERTS + url = 'https://www.metoffice.gov.uk/public/data/PWSCache/WarningsRSS/Region/nw' + try: + # get UK weather warnings + url = 'https://www.metoffice.gov.uk/weather/guides/rss' + response = requests.get(url) + soup = bs.BeautifulSoup(response.content, 'xml') + + items = soup.find_all('item') + alerts = [] + + for item in items: + title = item.find('title').get_text(strip=True) + description = item.find('description').get_text(strip=True) + alerts.append(f"🚨 {title}: {description}") + + return "\n".join(alerts) if alerts else NO_ALERTS + except Exception as e: + logger.warning("Error getting UK weather warnings: " + str(e)) + return NO_ALERTS + def get_floodUKgov(): # get UK flood warnings From a6ce9e92110b197763fccb170092b4bfa2b8381a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 20 Dec 2024 12:22:01 -0800 Subject: [PATCH 13/13] remove Numpy --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ac87b18..cf07d63 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,6 @@ requests maidenhead beautifulsoup4 dadjokes -numpy geopy schedule wikipedia