]> jfr.im git - erebus.git/commitdiff
added automatic topic changing
authorzonidjan <redacted>
Sun, 13 Dec 2015 09:58:23 +0000 (03:58 -0600)
committerzonidjan <redacted>
Sun, 13 Dec 2015 09:58:23 +0000 (03:58 -0600)
TODO
modules/trivia.py

diff --git a/TODO b/TODO
index 97b67597574b5118334df1f55de9931a1bf7f7fa..c7e109707d441361f20f81510cd564da5e56620a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -24,13 +24,11 @@ ctlmod: needs to print out a traceback. traceback.print_exc().
 [X] ability to modify parameters (HINTNUM, etc) & store in db instead of code
 [X] question management system done via irc
 [X] voting for next round target points
+[X] automatically change topic
 
 depends on userinfo:
        automatic periodically displaying top 10 by country (assigned countries by stored player stats)
 
-v1
-       automatically change topic
-
 v2
        multi-channel
        team play (Create/edit/addplayer/removeplayer) needs password & email address for team captain
index bf31f1c1fb75349f2684eefa9267e006e6c233d1..7dd460c3b470a8c6d5dfa65978069e3d79fa750c 100644 (file)
@@ -198,6 +198,8 @@ class TriviaState(object):
                        self.missedquestions += 1
                else:
                        self.missedquestions = 0
+                       if 'topicformat' in self.db and self.db['topicformat'] is not None:
+                               self.getbot().conn.send("TOPIC %s" % (self.db['chan']))
 
                if isinstance(self.steptimer, threading._Timer):
                        self.steptimer.cancel()
@@ -562,6 +564,24 @@ def num_417(bot, textline):
        bot.msg(state.db['chan'], "Whoops, it looks like that question didn't quite go through! (E:417). Let's try another...")
        state.nextquestion(qskipped=False, skipwait=True)
 
+@lib.hooknum(332)
+def num_TOPIC(bot, textline):
+       pieces = textline.split(None, 4)
+       chan = pieces[3]
+       if chan != state.db['chan']:
+               return
+       gottopic = pieces[4][1:]
+
+       formatted = state.db['topicformat'] % {
+               'chan': state.db['chan'],
+               'top': state.db['users'][state.db['ranks'][0]]['realnick'],
+               'top3': '/'.join([state.db['users'][state.db['ranks'][x]]['realnick'] for x in range(3) if x < len(state.db['ranks'])]),
+               'topscore': state.db['users'][state.db['ranks'][0]]['points'],
+               'target': state.db['target'],
+       }
+       if gottopic != formatted:
+               state.getbot().conn.send("TOPIC %s :%s" % (state.db['chan'], formatted))
+
 
 def specialQuestion(oldq):
        newq = [oldq[0], oldq[1]]