Added plant name in output message (#7)
Co-authored-by: aphelion <aphelion@envs.net> Co-authored-by: Arghyadeep <aphelion@envs.net> Reviewed-on: #7 Co-authored-by: Argy <aphelion@envs.net> Co-committed-by: Argy <aphelion@envs.net>
This commit is contained in:
parent
cd6f585434
commit
1cf36069c7
|
@ -7,22 +7,23 @@ def water(user):
|
||||||
visitors.append(dict(timestamp=int(time.time()),user="cosmicbot"))
|
visitors.append(dict(timestamp=int(time.time()),user="cosmicbot"))
|
||||||
with open(os.path.expanduser("~{}/.botany/visitors.json".format(user)),"w") as f:
|
with open(os.path.expanduser("~{}/.botany/visitors.json".format(user)),"w") as f:
|
||||||
json.dump(visitors,f,indent=2)
|
json.dump(visitors,f,indent=2)
|
||||||
return True # success
|
with open(os.path.expanduser("~{}/.botany/{}_plant_data.json".format(user,user))) as f:
|
||||||
|
return json.load(f)['description'] # Success
|
||||||
except:
|
except:
|
||||||
return False # failed
|
return False # Failure
|
||||||
|
|
||||||
@plugin.command("water")
|
@plugin.command("water")
|
||||||
def cmd_water(bot,channel,nick,user=None):
|
def cmd_water(bot,channel,nick,user=None):
|
||||||
if user is not None:
|
if user is not None:
|
||||||
if water(user):
|
if plant := water(user):
|
||||||
bot.say(channel,f"Watered {user}'s plant!")
|
bot.say(channel,f"Watered {user}'s {plant}!")
|
||||||
else:
|
else:
|
||||||
bot.say(channel,f"Unable to water {user}'s plant; are you sure they have one?")
|
bot.say(channel,f"Unable to water {user}'s plant; are you sure they have one?")
|
||||||
else:
|
else:
|
||||||
if water(nick):
|
if plant := water(nick):
|
||||||
bot.say(channel,f"Watered {nick}'s plant!")
|
bot.say(channel,f"Watered {nick}'s {plant}!")
|
||||||
return
|
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!")
|
bot.say(channel,f"Watered {bot.event.source.user}'s {plant}!")
|
||||||
return
|
return
|
||||||
bot.say(channel,"I couldn't figure out which plant was yours. Give me your username as an argument.")
|
bot.say(channel,"I couldn't figure out which plant was yours. Give me your username as an argument.")
|
||||||
|
|
Loading…
Reference in New Issue