From dc205412d9fc2e72b4ff7a462fb9927bf56ddc4a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Tue, 9 Jul 2024 02:28:37 -0700 Subject: [PATCH] wxalert --- README.md | 1 + mesh_bot.py | 10 +++++++++- modules/locationdata.py | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27440da..e382df1 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ other features - `whereami` returns the address of location of sender if known - `tide` returns the local tides, NOAA data source - `wx` and `wxc` returns local weather forcast, NOAA data source (wxc is metric value) + - `wxa` and `wxalert` returns NOAA alerts. short title or expanded details - `joke` tells a joke ### Configurations diff --git a/mesh_bot.py b/mesh_bot.py index 49a8743..d6e9ec5 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -30,7 +30,7 @@ trap_list = trap_list + trap_list_solarconditions # items hfcond, solar, sun, mo trap_list = trap_list + trap_list_bbs # items bbslist, bbspost, bbsread, bbsdelete, bbshelp welcome_message = "MeshBot, here for you like a friend who is not. Try sending: ping @foo or, help" -help_message = "CMD?: ping, motd, sitrep, joke, sun, hfcond, solar, moon, tide, whereami, wx, wxc, bbslist, bbshelp" +help_message = "CMD?: ping, motd, sitrep, joke, sun, hfcond, solar, moon, tide, whereami, wx, wxc, wxa, bbslist, bbshelp" MOTD = "Thanks for using PongBOT! Have a good day!" # Message of the Day RESPOND_BY_DM_ONLY = True # Set to True to respond messages via DM only (keeps the channel clean) @@ -99,6 +99,14 @@ def auto_response(message, snr, rssi, hop, message_from_id): location = get_node_location(message_from_id) moon = get_moon(str(location[0]),str(location[1])) bot_response = moon + elif "wxalert" in message.lower(): + location = get_node_location(message_from_id) + weatherAlert = get_wx_alert_details(str(location[0]),str(location[1])) + bot_response = weatherAlert[0] + elif "wxa" in message.lower(): + location = get_node_location(message_from_id) + weatherAlert = get_wx_alerts_list(str(location[0]),str(location[1])) + bot_response = weatherAlert[0] elif "wxc" in message.lower(): location = get_node_location(message_from_id) weather = get_weather(str(location[0]),str(location[1]),1) diff --git a/modules/locationdata.py b/modules/locationdata.py index 2f748b2..388468b 100644 --- a/modules/locationdata.py +++ b/modules/locationdata.py @@ -209,7 +209,7 @@ def get_wx_alerts_list(lat=0, lon=0): return "\n".join(alerts.split("\n")[:ALERT_COUNT]), alert_num def get_wx_alert_details(lat=0, lon=0): - # get the latest details of weather alerts from NOAA :: not used yet lotsa text + # get the latest details of weather alerts from NOAA alerts = "" if float(lat) == 0 and float(lon) == 0: return NO_DATA_NOGPS