Add first draft of goal command

This commit is contained in:
Robert Miles 2019-11-01 12:51:40 -04:00
parent ffcf857111
commit 1279b24de5
1 changed files with 20 additions and 0 deletions

20
commands/goal.py Normal file
View File

@ -0,0 +1,20 @@
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],"words")))
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))