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"
This commit is contained in:
Hemna 2021-07-09 11:24:46 -04:00
parent bcc605dc2c
commit d983e1a824
2 changed files with 23 additions and 163 deletions

View File

@ -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 = "<http://aprs.fi/info/a/{}|{}>".format(searchcall, searchcall)
aprs_url = "<http://aprs.fi/#!mt=roadmap&z=15&lat={}&lng={}|" " http://aprs.fi/>".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(
{

View File

@ -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