]> jfr.im git - erebus.git/commitdiff
finished target point voting
authorzonidjan <redacted>
Sun, 6 Sep 2015 02:00:38 +0000 (21:00 -0500)
committerzonidjan <redacted>
Sun, 6 Sep 2015 02:00:38 +0000 (21:00 -0500)
modules/contrib/trivia/trivia.json.example
modules/trivia.py

index eace9c7d0addada087bac98376fdaacc96e33703..b987ed57b4bbe912852bc96370a9206ad35d4bc2 100644 (file)
@@ -1,4 +1,6 @@
 {
+       "votetimer": 300,
+       "targetoptions": [500,1000,1337,1500],
        "hintnum": 3,
        "hinttimer": 20.0,
        "maxmissedquestions": 10,
index b4c0785b16c456f6a8e094427cea5425667871ac..74fd1425578ce12b165f49d485c0bb5c5edc69a1 100644 (file)
@@ -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: