janky fix to handle messages
This commit is contained in:
parent
b3434fa898
commit
bfe662ddaa
@ -11,8 +11,12 @@ openweathermap = OWM('593e0e182f9278a10443da354c4014db')
|
|||||||
|
|
||||||
def parse_loc(message):
|
def parse_loc(message):
|
||||||
if len(message.split()) > 1:
|
if len(message.split()) > 1:
|
||||||
return ' '.join(message.split()[1:])
|
try:
|
||||||
return '```Please input a location: !weather [location]```'
|
res = get_weather(' '.join(message.split()[1:]))
|
||||||
|
except exceptions.api_call_error.APICallError:
|
||||||
|
res = '```Please input a valid location: !weather [location]```'
|
||||||
|
return res
|
||||||
|
return '```Please input a valid location: !weather [location]```'
|
||||||
|
|
||||||
|
|
||||||
def get_weather(message):
|
def get_weather(message):
|
||||||
@ -24,9 +28,8 @@ def get_weather(message):
|
|||||||
|
|
||||||
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:
|
||||||
forecaster = openweathermap.three_hours_forecast(loc)
|
forecaster = openweathermap.three_hours_forecast(message)
|
||||||
forecast = forecaster.get_forecast()
|
forecast = forecaster.get_forecast()
|
||||||
|
|
||||||
reg = forecast.get(0)
|
reg = forecast.get(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user