Compare commits
No commits in common. "56d0e26c6d3802092f2edc60b9c1babab35f4748" and "31758b80b674b0adc5e8732bb8ed004bb12c4998" have entirely different histories.
56d0e26c6d
...
31758b80b6
@ -17,8 +17,9 @@ djangorestframework==3.9.4
|
|||||||
dodgy==0.1.9 # via prospector
|
dodgy==0.1.9 # via prospector
|
||||||
future==0.17.1 # via parsedatetime
|
future==0.17.1 # via parsedatetime
|
||||||
idna==2.8 # via requests
|
idna==2.8 # via requests
|
||||||
|
importlib-metadata==0.18 # via irc
|
||||||
inflect==2.1.0 # via jaraco.itertools
|
inflect==2.1.0 # via jaraco.itertools
|
||||||
irc==15.0.6
|
irc==17.1
|
||||||
isort==4.3.20 # via pylint
|
isort==4.3.20 # via pylint
|
||||||
jaraco.classes==2.0 # via jaraco.collections
|
jaraco.classes==2.0 # via jaraco.collections
|
||||||
jaraco.collections==2.0 # via irc
|
jaraco.collections==2.0 # via irc
|
||||||
@ -34,7 +35,7 @@ more-itertools==7.0.0 # via irc, jaraco.functools, jaraco.itertools
|
|||||||
oauthlib==3.0.1 # via requests-oauthlib
|
oauthlib==3.0.1 # via requests-oauthlib
|
||||||
parsedatetime==2.4
|
parsedatetime==2.4
|
||||||
pep8-naming==0.4.1 # via prospector
|
pep8-naming==0.4.1 # via prospector
|
||||||
pip-tools==4.1.0
|
pip-tools==3.8.0
|
||||||
ply==3.11
|
ply==3.11
|
||||||
prospector==1.1.6.4
|
prospector==1.1.6.4
|
||||||
pycodestyle==2.4.0 # via prospector
|
pycodestyle==2.4.0 # via prospector
|
||||||
@ -54,7 +55,7 @@ requests-oauthlib==1.2.0 # via twython
|
|||||||
requests==2.22.0 # via python-gitlab, requests-oauthlib, twython
|
requests==2.22.0 # via python-gitlab, requests-oauthlib, twython
|
||||||
requirements-detector==0.6 # via prospector
|
requirements-detector==0.6 # via prospector
|
||||||
setoptconf==0.2.0 # via prospector
|
setoptconf==0.2.0 # via prospector
|
||||||
six==1.12.0 # via astroid, django-extensions, irc, jaraco.classes, jaraco.collections, jaraco.itertools, jaraco.logging, jaraco.stream, logilab-common, pip-tools, pydocstyle, python-dateutil, python-gitlab, tempora
|
six==1.12.0 # via astroid, django-extensions, jaraco.classes, jaraco.collections, jaraco.itertools, jaraco.logging, jaraco.stream, logilab-common, pip-tools, pydocstyle, python-dateutil, python-gitlab, tempora
|
||||||
snowballstemmer==1.2.1 # via pydocstyle
|
snowballstemmer==1.2.1 # via pydocstyle
|
||||||
sqlparse==0.3.0 # via django
|
sqlparse==0.3.0 # via django
|
||||||
tempora==1.14.1 # via irc, jaraco.logging
|
tempora==1.14.1 # via irc, jaraco.logging
|
||||||
@ -62,6 +63,7 @@ twython==3.7.0
|
|||||||
typed-ast==1.4.0 # via astroid
|
typed-ast==1.4.0 # via astroid
|
||||||
urllib3==1.25.3 # via requests
|
urllib3==1.25.3 # via requests
|
||||||
wrapt==1.11.2 # via astroid
|
wrapt==1.11.2 # via astroid
|
||||||
|
zipp==0.5.1 # via importlib-metadata
|
||||||
|
|
||||||
# The following packages are considered to be unsafe in a requirements file:
|
# The following packages are considered to be unsafe in a requirements file:
|
||||||
# setuptools==41.2.0 # via logilab-common
|
# setuptools==41.0.1 # via logilab-common
|
||||||
|
@ -4,7 +4,7 @@ django-bootstrap3 # bootstrap layout
|
|||||||
django-extensions # more commands
|
django-extensions # more commands
|
||||||
django-registration-redux # registration views/forms
|
django-registration-redux # registration views/forms
|
||||||
djangorestframework # dispatch WS API
|
djangorestframework # dispatch WS API
|
||||||
irc==15.0.6 # core, pinned until I can bother to update --- 17.x has API changes
|
irc # core
|
||||||
parsedatetime # relative date stuff in countdown
|
parsedatetime # relative date stuff in countdown
|
||||||
ply # dice lex/yacc compiler
|
ply # dice lex/yacc compiler
|
||||||
python-dateutil # countdown relative math
|
python-dateutil # countdown relative math
|
||||||
|
@ -14,8 +14,9 @@ django==2.2.2
|
|||||||
djangorestframework==3.9.4
|
djangorestframework==3.9.4
|
||||||
future==0.17.1 # via parsedatetime
|
future==0.17.1 # via parsedatetime
|
||||||
idna==2.8 # via requests
|
idna==2.8 # via requests
|
||||||
|
importlib-metadata==0.18 # via irc
|
||||||
inflect==2.1.0 # via jaraco.itertools
|
inflect==2.1.0 # via jaraco.itertools
|
||||||
irc==15.0.6
|
irc==17.1
|
||||||
jaraco.classes==2.0 # via jaraco.collections
|
jaraco.classes==2.0 # via jaraco.collections
|
||||||
jaraco.collections==2.0 # via irc
|
jaraco.collections==2.0 # via irc
|
||||||
jaraco.functools==2.0 # via irc, jaraco.text, tempora
|
jaraco.functools==2.0 # via irc, jaraco.text, tempora
|
||||||
@ -33,8 +34,9 @@ python-mpd2==1.0.0
|
|||||||
pytz==2019.1
|
pytz==2019.1
|
||||||
requests-oauthlib==1.2.0 # via twython
|
requests-oauthlib==1.2.0 # via twython
|
||||||
requests==2.22.0 # via python-gitlab, requests-oauthlib, twython
|
requests==2.22.0 # via python-gitlab, requests-oauthlib, twython
|
||||||
six==1.12.0 # via django-extensions, irc, jaraco.classes, jaraco.collections, jaraco.itertools, jaraco.logging, jaraco.stream, python-dateutil, python-gitlab, tempora
|
six==1.12.0 # via django-extensions, jaraco.classes, jaraco.collections, jaraco.itertools, jaraco.logging, jaraco.stream, python-dateutil, python-gitlab, tempora
|
||||||
sqlparse==0.3.0 # via django
|
sqlparse==0.3.0 # via django
|
||||||
tempora==1.14.1 # via irc, jaraco.logging
|
tempora==1.14.1 # via irc, jaraco.logging
|
||||||
twython==3.7.0
|
twython==3.7.0
|
||||||
urllib3==1.25.3 # via requests
|
urllib3==1.25.3 # via requests
|
||||||
|
zipp==0.5.1 # via importlib-metadata
|
||||||
|
@ -33,27 +33,7 @@ class Weather(Plugin):
|
|||||||
if len(queryitems) <= 0:
|
if len(queryitems) <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
weather = weather_summary(queryitems[0])
|
return self.bot.reply(event, weather_summary(queryitems[0]))
|
||||||
weather_output = (f"Weather in {weather['location']}: {weather['current']['description']}. "
|
|
||||||
f"{weather['current']['temp_F']}/{weather['current']['temp_C']}, "
|
|
||||||
f"feels like {weather['current']['feels_like_temp_F']}/{weather['current']['feels_like_temp_C']}. "
|
|
||||||
f"Wind {weather['current']['wind_speed']} from the {weather['current']['wind_direction']}. "
|
|
||||||
f"Visibility {weather['current']['visibility']}. "
|
|
||||||
f"Precipitation {weather['current']['precipitation']}. "
|
|
||||||
f"Pressure {weather['current']['pressure']}. "
|
|
||||||
f"Cloud cover {weather['current']['cloud_cover']}. UV index {weather['current']['uv_index']}. "
|
|
||||||
f"Today: {weather['today_forecast']['noteworthy']}, "
|
|
||||||
f"High {weather['today_forecast']['high_F']}/{weather['today_forecast']['high_C']}, "
|
|
||||||
f"Low {weather['today_forecast']['low_F']}/{weather['today_forecast']['low_C']}. "
|
|
||||||
f"Tomorrow: {weather['tomorrow_forecast']['noteworthy']}, "
|
|
||||||
f"High {weather['tomorrow_forecast']['high_F']}/{weather['tomorrow_forecast']['high_C']}, "
|
|
||||||
f"Low {weather['tomorrow_forecast']['low_F']}/{weather['tomorrow_forecast']['low_C']}. "
|
|
||||||
f"Day after tomorrow: {weather['day_after_tomorrow_forecast']['noteworthy']}, "
|
|
||||||
f"High {weather['day_after_tomorrow_forecast']['high_F']}/{weather['day_after_tomorrow_forecast']['high_C']}, "
|
|
||||||
f"Low {weather['day_after_tomorrow_forecast']['low_F']}/{weather['day_after_tomorrow_forecast']['low_C']}."
|
|
||||||
)
|
|
||||||
|
|
||||||
return self.bot.reply(event, weather_output)
|
|
||||||
|
|
||||||
|
|
||||||
plugin = Weather
|
plugin = Weather
|
||||||
|
@ -19,7 +19,6 @@ def query_wttr_in(query):
|
|||||||
|
|
||||||
def weather_summary(query):
|
def weather_summary(query):
|
||||||
"""Create a more consumable version of the weather report."""
|
"""Create a more consumable version of the weather report."""
|
||||||
logger.info(f"assembling weather summary for '{query}")
|
|
||||||
weather_info = query_wttr_in(query)
|
weather_info = query_wttr_in(query)
|
||||||
|
|
||||||
# get some common/nested stuff once now
|
# get some common/nested stuff once now
|
||||||
@ -29,18 +28,6 @@ def weather_summary(query):
|
|||||||
tomorrow_forecast = weather_info['weather'][1]
|
tomorrow_forecast = weather_info['weather'][1]
|
||||||
day_after_tomorrow_forecast = weather_info['weather'][2]
|
day_after_tomorrow_forecast = weather_info['weather'][2]
|
||||||
|
|
||||||
today_notes = [{'code': int(item['weatherCode']), 'desc': item['weatherDesc'][0]['value'] }
|
|
||||||
for item in today_forecast['hourly']]
|
|
||||||
today_noteworthy = sorted(today_notes, key=lambda i: i['code'], reverse=True)[0]['desc']
|
|
||||||
|
|
||||||
tomorrow_notes = [{'code': int(item['weatherCode']), 'desc': item['weatherDesc'][0]['value'] }
|
|
||||||
for item in tomorrow_forecast['hourly']]
|
|
||||||
tomorrow_noteworthy = sorted(tomorrow_notes, key=lambda i: i['code'], reverse=True)[0]['desc']
|
|
||||||
|
|
||||||
day_after_tomorrow_notes = [{'code': int(item['weatherCode']), 'desc': item['weatherDesc'][0]['value'] }
|
|
||||||
for item in day_after_tomorrow_forecast['hourly']]
|
|
||||||
day_after_tomorrow_noteworthy = sorted(day_after_tomorrow_notes, key=lambda i: i['code'], reverse=True)[0]['desc']
|
|
||||||
|
|
||||||
summary = {
|
summary = {
|
||||||
'location': query,
|
'location': query,
|
||||||
'current': {
|
'current': {
|
||||||
@ -54,32 +41,10 @@ def weather_summary(query):
|
|||||||
'precipitation': f"{current.get('precipMM')} mm",
|
'precipitation': f"{current.get('precipMM')} mm",
|
||||||
'visibility': f"{current.get('visibility')} mi",
|
'visibility': f"{current.get('visibility')} mi",
|
||||||
'wind_speed': f"{current.get('windspeedMiles')} MPH",
|
'wind_speed': f"{current.get('windspeedMiles')} MPH",
|
||||||
'wind_direction': current.get('winddir16Point'),
|
'wind_direction': f"{current.get('winddir16Point')}",
|
||||||
'pressure': f"{current.get('pressure')} mb",
|
'pressure': f"{current.get('pressure')} mb",
|
||||||
'uv_index': current.get('uvIndex'),
|
'uv_index': f"{current.get('uvIndex')}",
|
||||||
},
|
|
||||||
'today_forecast': {
|
|
||||||
'high_C': f"{today_forecast.get('maxtempC')}°C",
|
|
||||||
'high_F': f"{today_forecast.get('maxtempF')}°F",
|
|
||||||
'low_C': f"{today_forecast.get('mintempC')}°C",
|
|
||||||
'low_F': f"{today_forecast.get('mintempF')}°F",
|
|
||||||
'noteworthy': today_noteworthy,
|
|
||||||
},
|
|
||||||
'tomorrow_forecast': {
|
|
||||||
'high_C': f"{tomorrow_forecast.get('maxtempC')}°C",
|
|
||||||
'high_F': f"{tomorrow_forecast.get('maxtempF')}°F",
|
|
||||||
'low_C': f"{tomorrow_forecast.get('mintempC')}°C",
|
|
||||||
'low_F': f"{tomorrow_forecast.get('mintempF')}°F",
|
|
||||||
'noteworthy': tomorrow_noteworthy,
|
|
||||||
},
|
|
||||||
'day_after_tomorrow_forecast': {
|
|
||||||
'high_C': f"{day_after_tomorrow_forecast.get('maxtempC')}°C",
|
|
||||||
'high_F': f"{day_after_tomorrow_forecast.get('maxtempF')}°F",
|
|
||||||
'low_C': f"{day_after_tomorrow_forecast.get('mintempC')}°C",
|
|
||||||
'low_F': f"{day_after_tomorrow_forecast.get('mintempF')}°F",
|
|
||||||
'noteworthy': day_after_tomorrow_noteworthy,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(f"results: {summary}")
|
|
||||||
return summary
|
return summary
|
||||||
|
Loading…
x
Reference in New Issue
Block a user