]> jfr.im git - erebus.git/blobdiff - modules/trivia.py
minor bugfix and convenience function lib.mod(modname) in modlib
[erebus.git] / modules / trivia.py
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]]