handle string inputs
This commit is contained in:
parent
2e4354bc71
commit
4a59bd0506
@ -7,8 +7,15 @@ emojis = {'clear sky': ':sunny:', 'scattered clouds': ':partly_sunny:',
|
|||||||
'light rain': ':white_sun_rain_cloud:', 'overcast clouds': ':cloud:',
|
'light rain': ':white_sun_rain_cloud:', 'overcast clouds': ':cloud:',
|
||||||
'broken clouds': ':white_sun_cloud:', 'moderate rain': ':cloud_with_rain:',
|
'broken clouds': ':white_sun_cloud:', 'moderate rain': ':cloud_with_rain:',
|
||||||
'light snow': ':cloud_snow:', 'few clouds': ':white_sun_small_cloud:'}
|
'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)
|
get_weather(location)
|
||||||
|
|
||||||
@ -17,8 +24,8 @@ def get_weather(location):
|
|||||||
|
|
||||||
TODO: Replace basic code block with nice looking, bold text w/ emojis
|
TODO: Replace basic code block with nice looking, bold text w/ emojis
|
||||||
"""
|
"""
|
||||||
|
loc = parse_loc(message)
|
||||||
try:
|
try:
|
||||||
openweathermap = OWM('593e0e182f9278a10443da354c4014db')
|
|
||||||
forecaster = openweathermap.three_hours_forecast(location)
|
forecaster = openweathermap.three_hours_forecast(location)
|
||||||
forecast = forecaster.get_forecast()
|
forecast = forecaster.get_forecast()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user