+@lib.hook(glevel=lib.STAFF, needchan=False)
+def addq(bot, user, chan, realtarget, *args):
+ line = ' '.join([str(arg) for arg in args])
+ linepieces = line.split('*')
+ if len(linepieces) < 2:
+ bot.msg(user, "Error: need <question>*<answer>")
+ return
+ question = linepieces[0].strip()
+ answer = linepieces[1].strip()
+ state.db['questions'].append([question, answer])
+ bot.msg(user, "Done. Question is #%s" % (len(state.db['questions'])-1))
+
+
+@lib.hook(needchan=False)
+def triviahelp(bot, user, chan, realtarget, *args):
+ bot.msg(user, "START")
+ bot.msg(user, "TOP10")
+ bot.msg(user, "POINTS [<user>]")
+ bot.msg(user, "RANK [<user>]")
+ bot.msg(user, "BADQ <reason> (include info to identify question)")
+ if user.glevel >= 1:
+ bot.msg(user, "SKIP (>=KNOWN)")
+ bot.msg(user, "STOP (>=KNOWN)")
+ bot.msg(user, "FINDQ <question> (>=KNOWN)")
+ if user.glevel >= lib.STAFF:
+ bot.msg(user, "GIVE <user> [<points>] (>=STAFF)")
+ bot.msg(user, "SETNEXT <q>*<a> (>=STAFF)")
+ bot.msg(user, "ADDQ <q>*<a> (>=STAFF)")
+ bot.msg(user, "DELETEQ <q>*<a> (>=STAFF) [aka DELQ]")
+ bot.msg(user, "BADQS (>=STAFF)")
+ bot.msg(user, "CLEARBADQS (>=STAFF)")
+ bot.msg(user, "DELBADQ <reportid> (>=STAFF)")
+ if user.glevel >= lib.ADMIN:
+ bot.msg(user, "SETTARGET <points> (>=ADMIN)")
+ bot.msg(user, "MAXMISSED <questions> (>=ADMIN)")
+ bot.msg(user, "HINTTIMER <float seconds> (>=ADMIN)")
+ bot.msg(user, "HINTNUM <hints> (>=ADMIN)")
+ bot.msg(user, "QUESTIONPAUSE <float seconds> (>=ADMIN)")
+
+@lib.hooknum(417)
+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'],
+ 'top1': "%s (%s)" % (person(0), pts(0)),
+ 'top3': '/'.join([
+ "%s (%s)" % (person(x), pts(x))
+ for x in range(3) if x < len(state.db['ranks'])
+ ]),
+ 'top3c': ' '.join([
+ "%s (%s, %s)" % (person(x), pts(x), country(x))
+ for x in range(3) if x < len(state.db['ranks'])
+ ]),
+ 'top10': ' '.join([
+ "%s (%s)" % (person(x), pts(x))
+ for x in range(10) if x < len(state.db['ranks'])
+ ]),
+ 'top10c': ' '.join([
+ "%s (%s, %s)" % (person(x), pts(x), country(x))
+ for x in range(10) if x < len(state.db['ranks'])
+ ]),
+ 'lastwinner': state.db['lastwinner'],
+ 'lastwon': time.strftime("%b %d", time.gmtime(state.db['lastwon'])),
+ 'target': state.db['target'],
+ }
+ if gottopic != formatted:
+ state.getbot().conn.send("TOPIC %s :%s" % (state.db['chan'], formatted))