Skip to content

Commit

Permalink
Fix formatting issue in weather plugin
Browse files Browse the repository at this point in the history
The API appears to be returning some unwanted whitespace, so strip() it.
  • Loading branch information
johnmaguire committed Dec 8, 2020
1 parent 312af7d commit 096ce79
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugins/weather/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def set_weather(self, cardinal, user, channel, msg):

try:
res = self.get_forecast(location).json()
location = "{}, {}, {}".format(res['location']['city'],
res['location']['region'],
res['location']['country'])
location = "{}, {}, {}".format(res['location']['city'].strip(),
res['location']['region'].strip(),
res['location']['country'].strip())
except Exception:
cardinal.sendMsg(channel, "Sorry, I can't find that location.")
self.logger.exception(
Expand Down Expand Up @@ -133,9 +133,9 @@ def weather(self, cardinal, user, channel, msg):
return

try:
location = "{}, {}, {}".format(res['location']['city'],
res['location']['region'],
res['location']['country'])
location = "{}, {}, {}".format(res['location']['city'].strip(),
res['location']['region'].strip(),
res['location']['country'].strip())
except KeyError:
cardinal.sendMsg(channel,
"Couldn't find weather data for your location.")
Expand Down

0 comments on commit 096ce79

Please sign in to comment.