Added plant name in output message #7
|
@ -1,12 +1,15 @@
|
|||
import plugin, os.path, json, time
|
||||
|
||||
def water(user):
|
||||
try:
|
||||
try:
|
||||
with open(os.path.expanduser("~{}/.botany/visitors.json".format(user))) as f:
|
||||
visitors = json.load(f)
|
||||
visitors.append(dict(timestamp=int(time.time()),user="cosmicbot"))
|
||||
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_data['description']
|
||||
return True # success
|
||||
except:
|
||||
return False # failed
|
||||
|
@ -15,14 +18,14 @@ def water(user):
|
|||
def cmd_water(bot,channel,nick,user=None):
|
||||
if user is not None:
|
||||
if water(user):
|
||||
bot.say(channel,f"Watered {user}'s plant!")
|
||||
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):
|
||||
bot.say(channel,f"Watered {nick}'s plant!")
|
||||
bot.say(channel,f"Watered {nick}'s {plant}!")
|
||||
return
|
||||
if 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
|
||||
bot.say(channel,"I couldn't figure out which plant was yours. Give me your username as an argument.")
|
||||
|
|
Loading…
Reference in New Issue
Block a user