From 1000be3ea1afce58893cd085c81be629333f6c8c Mon Sep 17 00:00:00 2001 From: Alex Vidal Date: Tue, 30 Dec 2014 14:24:57 -0600 Subject: [PATCH] Don't include " dontsave" when displaying weather API failures The weather plugin will reply with "Could not find weather for " when the API response doesn't include the "current_observation" key. However, when the user appends " dontsave" to the query that gets reported back to the user and confuses the shit out of everyone. --- plugins/weather.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/weather.py b/plugins/weather.py index 8fe076c..3a8395b 100644 --- a/plugins/weather.py +++ b/plugins/weather.py @@ -22,11 +22,12 @@ def weather(inp, chan='', nick='', reply=None, db=None, api_key=None): loc = None dontsave = True else: - loc = inp - - dontsave = loc.endswith(" dontsave") + dontsave = inp.endswith(" dontsave") + # strip off the " dontsave" text if it exists and set it back to `inp` so we don't report it + # back to the user incorrectly if dontsave: - loc = loc[:-9].strip().lower() + inp = inp[:-9].strip().lower() + loc = inp if not loc: # blank line loc = db.execute(