From: zonidjan Date: Sun, 6 Sep 2015 02:00:38 +0000 (-0500) Subject: finished target point voting X-Git-Url: https://jfr.im/git/erebus.git/commitdiff_plain/38b299931dd85d47d99f11629b41cb5bca40d53d finished target point voting --- diff --git a/modules/contrib/trivia/trivia.json.example b/modules/contrib/trivia/trivia.json.example index eace9c7..b987ed5 100644 --- a/modules/contrib/trivia/trivia.json.example +++ b/modules/contrib/trivia/trivia.json.example @@ -1,4 +1,6 @@ { + "votetimer": 300, + "targetoptions": [500,1000,1337,1500], "hintnum": 3, "hinttimer": 20.0, "maxmissedquestions": 10, diff --git a/modules/trivia.py b/modules/trivia.py index b4c0785..74fd142 100644 --- a/modules/trivia.py +++ b/modules/trivia.py @@ -138,6 +138,8 @@ class TriviaState(object): self.db['target'] = votelist[-1][0] self.pointvote = None + self.nextquestion() #start the game! + def nextquestion(self, qskipped=False, iteration=0): if self.gameover == True: return self.doGameOver() @@ -361,9 +363,25 @@ def cmd_settarget(bot, user, chan, realtarget, *args): try: state.db['target'] = int(args[0]) bot.msg(state.db['chan'], "Target has been changed to %s points!" % (state.db['target'])) + + if state.votetimer is not None: + state.votetimer.cancel() + state.votetimer = None + bot.msg(state.db['chan'], "Vote has been cancelled!") except: bot.msg(user, "Failed to set target.") +@lib.hook('vote', needchan=False) +def cmd_vote(bot, user, chan, realtarget, *args): + if state.votetimer is not None: + if int(args[0]) in state.voteamounts: + state.voteamounts[int(args[0])] += 1 + bot.msg(user, "Your vote has been recorded.") + else: + bot.msg(user, "Sorry - that's not an option!") + else: + bot.msg(user, "There's no vote in progress.") + @lib.hook('maxmissed', clevel=lib.MASTER, needchan=False) def cmd_maxmissed(bot, user, chan, realtarget, *args): try: