From d983e1a824f3bd684bee98e4601a12346d7803a6 Mon Sep 17 00:00:00 2001 From: Hemna Date: Fri, 9 Jul 2021 11:24:46 -0400 Subject: [PATCH] Added geo description in location. Unfortunately, this currently only works in the US. need a global reverse geolocation service that provides an area description "6 miles northeast of X" --- aprsd_slack_plugin/location_plugin.py | 23 +++- requirements.txt | 163 +------------------------- 2 files changed, 23 insertions(+), 163 deletions(-) diff --git a/aprsd_slack_plugin/location_plugin.py b/aprsd_slack_plugin/location_plugin.py index e9f051a..cce3c20 100644 --- a/aprsd_slack_plugin/location_plugin.py +++ b/aprsd_slack_plugin/location_plugin.py @@ -92,12 +92,15 @@ class SlackLocationPlugin(base_plugin.SlackPluginBase): alt = 0 altfeet = int(alt * 3.28084) aprs_lasttime_seconds = aprs_data["entries"][0]["lasttime"] - # aprs_lasttime_seconds = aprs_lasttime_seconds.encode( - # "ascii", errors="ignore" - # ) # unicode to ascii delta_seconds = time.time() - int(aprs_lasttime_seconds) delta_hours = delta_seconds / 60 / 60 + wx_data = None + try: + wx_data = plugin_utils.get_weather_gov_for_gps(lat, lon) + except Exception: + LOG.warning("Couldn't fetch forecast.weather.gov") + callsign_url = "".format(searchcall, searchcall) aprs_url = "".format( @@ -115,8 +118,20 @@ class SlackLocationPlugin(base_plugin.SlackPluginBase): attachment = message["attachments"][0] attachment["fallback"] = message["text"] attachment["fields"] = [] + + # if the coordinates are outside of the US, we don't get this + # aread description + if wx_data and "location" in wx_data and "areaDescription" in wx_data["location"]: + attachment["fields"].append( + { + "title": "Location", + "value": wx_data["location"]["areaDescription"], + "short": True, + }, + ) + attachment["fields"].append( - {"title": "Location", "value": aprs_url, "short": True}, + {"title": "Map Location", "value": aprs_url, "short": True}, ) attachment["fields"].append( { diff --git a/requirements.txt b/requirements.txt index a6838f2..8e2176a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,159 +1,4 @@ -# -# This file is autogenerated by pip-compile -# To update, run: -# -# pip-compile requirements.in -# -aprsd==1.6.1 - # via -r requirements.in -aprslib==0.6.47 - # via aprsd -backoff==1.10.0 - # via - # aprsd - # opencage -certifi==2020.12.5 - # via - # aprsd - # requests -cffi==1.14.4 - # via - # aprsd - # cryptography -chardet==4.0.0 - # via - # aprsd - # requests -click-completion==0.5.2 - # via aprsd -click==7.1.2 - # via - # aprsd - # click-completion - # flask -cryptography==3.3.2 - # via - # aprsd - # pyopenssl -dnspython==2.1.0 - # via - # aprsd - # py3-validate-email -filelock==3.0.12 - # via - # aprsd - # py3-validate-email -flask-classful==0.14.2 - # via aprsd -flask-httpauth==4.2.0 - # via aprsd -flask==1.1.2 - # via - # aprsd - # flask-classful - # flask-httpauth - # slackeventsapi -idna==2.10 - # via - # aprsd - # py3-validate-email - # requests -imapclient==2.2.0 - # via aprsd -itsdangerous==1.1.0 - # via - # aprsd - # flask - # slackeventsapi -jinja2==2.11.3 - # via - # aprsd - # click-completion - # flask - # slackeventsapi -lxml==4.6.3 - # via - # aprsd - # yfinance -markupsafe==1.1.1 - # via - # aprsd - # jinja2 - # slackeventsapi -multitasking==0.0.9 - # via - # aprsd - # yfinance -numpy==1.20.1 - # via - # aprsd - # pandas - # yfinance -opencage==1.2.2 - # via aprsd -pandas==1.2.2 - # via - # aprsd - # yfinance -pbr==5.5.1 - # via - # -r requirements.in - # aprsd -pluggy==0.13.1 - # via aprsd -py3-validate-email==0.2.12 - # via aprsd -pycparser==2.20 - # via - # aprsd - # cffi -pyee==7.0.4 - # via slackeventsapi -pyopenssl==20.0.1 - # via - # aprsd - # opencage -python-dateutil==2.8.1 - # via - # aprsd - # pandas -pytz==2020.5 - # via - # aprsd - # pandas -pyyaml==5.4.1 - # via aprsd -requests==2.25.1 - # via - # aprsd - # opencage - # yfinance -shellingham==1.3.2 - # via - # aprsd - # click-completion -six==1.15.0 - # via - # aprsd - # click-completion - # cryptography - # imapclient - # opencage - # pyopenssl - # python-dateutil -slack-sdk==3.6.0 - # via -r requirements.in -slackeventsapi==2.2.1 - # via -r requirements.in -thesmuggler==1.0.1 - # via aprsd -urllib3==1.26.3 - # via - # aprsd - # requests -werkzeug==1.0.1 - # via - # aprsd - # flask -yfinance==0.1.55 - # via aprsd +pbr +slack_sdk>=3.0 +slackeventsapi>=2.1.0 +aprsd>=1.5.2