Removed global var

This commit is contained in:
Argy 2021-06-23 14:55:15 +00:00
parent a69878043a
commit 03bcabfa94
1 changed files with 5 additions and 8 deletions

View File

@ -8,25 +8,22 @@ def water(user):
with open(os.path.expanduser("~{}/.botany/visitors.json".format(user)),"w") as f:
json.dump(visitors,f,indent=2)
with open(os.path.expanduser("~{}/.botany/{}_plant_data.json".format(user,user))) as f:
plant_data = json.load(f)
global plant
plant = plant_data['description']
return True # success
return json.load(f)['description'] # Success
except:
return False # failed
return "" # Failure
@plugin.command("water")
def cmd_water(bot,channel,nick,user=None):
if user is not None:
if water(user):
if plant := water(user):
bot.say(channel,f"Watered {user}'s {plant}!")
else:
bot.say(channel,f"Unable to water {user}'s plant; are you sure they have one?")
else:
if water(nick):
if plant := water(nick):
bot.say(channel,f"Watered {nick}'s {plant}!")
return
if water(bot.event.source.user):
if plant := water(bot.event.source.user):
bot.say(channel,f"Watered {bot.event.source.user}'s {plant}!")
return
bot.say(channel,"I couldn't figure out which plant was yours. Give me your username as an argument.")