mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-08-07 09:22:44 +02:00
england.GovAlert
This commit is contained in:
+4
-1
@@ -277,7 +277,10 @@ def handle_motd(message, message_from_id, isDM):
|
||||
|
||||
def handle_wxalert(message_from_id, deviceID, message):
|
||||
if use_meteo_wxApi:
|
||||
return "wxalert is not supported"
|
||||
if useEUalerts:
|
||||
return get_govUK_alerts()
|
||||
else:
|
||||
return "wxalert is not supported"
|
||||
else:
|
||||
location = get_node_location(message_from_id, deviceID)
|
||||
if "wxalert" in message:
|
||||
|
||||
@@ -12,14 +12,19 @@ from modules.log import *
|
||||
trap_list_location_eu = ("ukalert", "ukwx", "ukflood")
|
||||
|
||||
def get_govUK_alerts():
|
||||
# get UK weather alerts
|
||||
url = 'https://www.gov.uk/alerts'
|
||||
response = requests.get(url)
|
||||
soup = bs.BeautifulSoup(response.text, 'html.parser')
|
||||
# the alerts are in <h2 class="govuk-heading-m" id="alert-status">
|
||||
alert = soup.find('h2', class_='govuk-heading-m', id='alert-status')
|
||||
try:
|
||||
# get UK.gov alerts
|
||||
url = 'https://www.gov.uk/alerts'
|
||||
response = requests.get(url)
|
||||
soup = bs.BeautifulSoup(response.text, 'html.parser')
|
||||
# the alerts are in <h2 class="govuk-heading-m" id="alert-status">
|
||||
alert = soup.find('h2', class_='govuk-heading-m', id='alert-status')
|
||||
except Exception as e:
|
||||
logger.warning("Error getting UK alerts: " + str(e))
|
||||
return "System: Error getting UK alerts"
|
||||
|
||||
if alert:
|
||||
return alert.get_text(strip=True)
|
||||
return "🚨" + alert.get_text(strip=True)
|
||||
else:
|
||||
return "No alerts"
|
||||
|
||||
|
||||
+1
-1
@@ -155,7 +155,7 @@ try:
|
||||
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
|
||||
includeEUalerts = config['location'].getboolean('includeEUalerts', False) # default False
|
||||
useEUalerts = config['location'].getboolean('includeEUalerts', 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
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ if location_enabled:
|
||||
from modules.locationdata import * # from the spudgunman/meshing-around repo
|
||||
trap_list = trap_list + trap_list_location # items tide, whereami, wxc, wx
|
||||
help_message = help_message + ", whereami, wx, wxc, rlist"
|
||||
if includeEUalerts:
|
||||
if useEUalerts:
|
||||
from modules.locationdata_eu import * # from the spudgunman/meshing-around repo
|
||||
trap_list = trap_list + trap_list_location_eu
|
||||
#help_message = help_message + ", ukalert, ukwx, ukflood"
|
||||
|
||||
Reference in New Issue
Block a user