Last active
August 29, 2015 14:09
-
-
Save fuzzy/df8c7e113acb8037e3e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- weather.py 2014-11-18 13:29:26.346413808 -0800 | |
+++ weathernew.py 2014-11-18 14:00:28.478386947 -0800 | |
@@ -6,7 +6,7 @@ | |
@hook.api_key('wunderground') | |
@hook.command(autohelp=False) | |
def weather(inp, chan='', nick='', reply=None, db=None, api_key=None): | |
- ".weather <location> [dontsave] | @<nick> -- gets weather data from Wunderground "\ | |
+ ".weather <location> [dontsave] | @<nick> | [forget] -- gets weather data from Wunderground "\ | |
"http://wunderground.com/weather/api" | |
if not api_key: | |
@@ -17,14 +17,21 @@ | |
db.execute( | |
"create table if not exists location(chan, nick, loc, lat, lon, primary key(chan, nick))") | |
+ dontsave = False | |
+ forget = False | |
+ | |
if inp[0:1] == '@': | |
nick = inp[1:].strip() | |
loc = None | |
dontsave = True | |
+ elif inp == 'forget': | |
+ forget = True | |
+ loc = None | |
else: | |
loc = inp | |
- dontsave = loc.endswith(" dontsave") | |
+ dontsave = tkn.endswith('dontsave'): | |
+ | |
if dontsave: | |
loc = loc[:-9].strip().lower() | |
@@ -115,7 +122,9 @@ | |
lat = float(obs['display_location']['latitude']) | |
lon = float(obs['display_location']['longitude']) | |
- if inp and not dontsave: | |
+ if inp and not dontsave and not forget: | |
db.execute("insert or replace into location(chan, nick, loc, lat, lon) " | |
"values (?, ?, ?, ?,?)", (chan, nick.lower(), inp, lat, lon)) | |
- db.commit() | |
+ elif inp and not dontsave and forget: | |
+ db.execute("delete from location where nick = '?' and chan = '?'", (nick.lower(), chan)) | |
+ db.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment