diff --git a/app/weather.py b/app/weather.py index 311ae871..c57e32be 100644 --- a/app/weather.py +++ b/app/weather.py @@ -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()