From ceaddaebae1b631a8927a8a96be670fa4323ad11 Mon Sep 17 00:00:00 2001 From: Jacob Stultz Date: Sun, 2 Feb 2014 12:03:34 -0800 Subject: [PATCH] Show weather for other users --- plugins/weather.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/weather.py b/plugins/weather.py index 4898818..3443c11 100644 --- a/plugins/weather.py +++ b/plugins/weather.py @@ -6,8 +6,8 @@ from util import hook, http @hook.api_key('wunderground') @hook.command(autohelp=False) def weather(inp, chan='', nick='', reply=None, db=None, api_key=None): - ".weather [dontsave] -- gets weather data from Wunderground "\ - "http://wunderground.com/weather/api" + ".weather [dontsave] | @ -- gets weather data from Wunderground "\ + "http://wunderground.com/weather/api" if not api_key: return None @@ -17,11 +17,16 @@ def weather(inp, chan='', nick='', reply=None, db=None, api_key=None): db.execute( "create table if not exists location(chan, nick, loc, lat, lon, primary key(chan, nick))") - loc = inp + if inp[0:1] == '@': + nick = inp[1:].strip() + loc = None + dontsave = True + else: + loc = inp - dontsave = loc.endswith(" dontsave") - if dontsave: - loc = loc[:-9].strip().lower() + dontsave = loc.endswith(" dontsave") + if dontsave: + loc = loc[:-9].strip().lower() if not loc: # blank line loc = db.execute(