handle string inputs

This commit is contained in:
Jason Ji 2017-09-21 18:30:34 -07:00
parent f19d3754f6
commit 43003f7a6b

View File

@ -7,8 +7,15 @@ emojis = {'clear sky': ':sunny:', 'scattered clouds': ':partly_sunny:',
'light rain': ':white_sun_rain_cloud:', 'overcast clouds': ':cloud:',
'broken clouds': ':white_sun_cloud:', 'moderate rain': ':cloud_with_rain:',
'light snow': ':cloud_snow:', 'few clouds': ':white_sun_small_cloud:'}
openweathermap = OWM('593e0e182f9278a10443da354c4014db')
def get_weather(location):
def parse_loc(message):
if len(message.split()) > 1:
return ' '.join(message.split()[1:])
return '```Please input a location: !weather [location]```'
def get_weather(message):
"""
get_weather(location)
@ -17,8 +24,8 @@ def get_weather(location):
TODO: Replace basic code block with nice looking, bold text w/ emojis
"""
loc = parse_loc(message)
try:
openweathermap = OWM('593e0e182f9278a10443da354c4014db')
forecaster = openweathermap.three_hours_forecast(location)
forecast = forecaster.get_forecast()