Added "dontsave" functionality to .weather
This commit is contained in:
parent
e07d6486b3
commit
3dcb0dd537
|
@ -32,7 +32,7 @@ def save_stalk(filename, houses):
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def weather(bot, input):
|
def weather(bot, input):
|
||||||
".weather <location> -- queries the google weather API for weather data"
|
".weather <location> [dontsave] -- queries the google weather API for weather data"
|
||||||
global stalk
|
global stalk
|
||||||
|
|
||||||
filename = os.path.join(bot.persist_dir, 'weather')
|
filename = os.path.join(bot.persist_dir, 'weather')
|
||||||
|
@ -41,7 +41,10 @@ def weather(bot, input):
|
||||||
stalk = load_stalk(filename)
|
stalk = load_stalk(filename)
|
||||||
|
|
||||||
nick = input.nick.lower()
|
nick = input.nick.lower()
|
||||||
loc = input.inp.strip().lower()
|
loc = input.inp.strip()
|
||||||
|
dontsave = loc.endswith(" dontsave")
|
||||||
|
if dontsave:
|
||||||
|
loc = loc[:-9].strip().lower()
|
||||||
if not loc: # blank line
|
if not loc: # blank line
|
||||||
loc = stalk.get(nick, '')
|
loc = stalk.get(nick, '')
|
||||||
if not loc:
|
if not loc:
|
||||||
|
@ -60,10 +63,10 @@ def weather(bot, input):
|
||||||
info['high'] = w.find('forecast_conditions/high').get('data')
|
info['high'] = w.find('forecast_conditions/high').get('data')
|
||||||
info['low'] = w.find('forecast_conditions/low').get('data')
|
info['low'] = w.find('forecast_conditions/low').get('data')
|
||||||
|
|
||||||
input.reply('%(city)s: %(condition)s, %(temp_f)sF/%(temp_c)sC (H:%(high)s'\
|
bot.reply('%(city)s: %(condition)s, %(temp_f)sF/%(temp_c)sC (H:%(high)sF'\
|
||||||
'F, L:%(low)sF), %(humidity)s, %(wind_condition)s.' % info)
|
', L:%(low)sF), %(humidity)s, %(wind_condition)s.' % info)
|
||||||
|
|
||||||
if loc != stalk.get(nick, ''):
|
if not dontsave and loc != stalk.get(nick, ''):
|
||||||
with lock:
|
with lock:
|
||||||
stalk[nick] = loc
|
stalk[nick] = loc
|
||||||
save_stalk(filename, stalk)
|
save_stalk(filename, stalk)
|
||||||
|
|
Loading…
Reference in New Issue