cosmicbot/commands/goal.py

21 lines
602 B
Python

import plugin, time
from dictdata import DictData
from pluralslib import plural
goal = DictData("goals.json")
def set_goal(nick,goal_):
goal[nick] = [goal_,time.time()/1000]
@plugin.command("goal","[goal]")
def goal_cmd(bot,channel,nick,goal_=""):
if not goal_:
if nick in goal and ((time.time()/1000)-goal[nick][1])<(24*60*60):
bot.say(channel,"{}: Your goal is {}.".format(nick,plural(goal[nick][0],"word")))
else:
bot.say(channel,"{}: You haven't set a goal today!".format(nick))
else:
goal_ = int(goal_)
set_goal(nick,goal_)
bot.say(channel,"{}: Set your goal!".format(nick))