+@lib.hook(needchan=False)
+def vote(bot, user, chan, realtarget, *args):
+ if state.pointvote 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(glevel=lib.ADMIN, needchan=False)
+def maxmissed(bot, user, chan, realtarget, *args):
+ try:
+ state.db['maxmissedquestions'] = int(args[0])
+ bot.msg(state.db['chan'], "Max missed questions before round ends has been changed to %s." % (state.db['maxmissedquestions']))
+ except:
+ bot.msg(user, "Failed to set maxmissed.")
+
+@lib.hook(glevel=lib.ADMIN, needchan=False)
+def hinttimer(bot, user, chan, realtarget, *args):
+ try:
+ state.db['hinttimer'] = float(args[0])
+ bot.msg(state.db['chan'], "Time between hints has been changed to %s." % (state.db['hinttimer']))
+ except:
+ bot.msg(user, "Failed to set hint timer.")
+
+@lib.hook(glevel=lib.ADMIN, needchan=False)
+def hintnum(bot, user, chan, realtarget, *args):
+ try:
+ state.db['hintnum'] = int(args[0])
+ bot.msg(state.db['chan'], "Max number of hints has been changed to %s." % (state.db['hintnum']))
+ except:
+ bot.msg(user, "Failed to set hintnum.")
+
+@lib.hook(glevel=lib.ADMIN, needchan=False)
+def questionpause(bot, user, chan, realtarget, *args):
+ try:
+ state.db['questionpause'] = float(args[0])
+ bot.msg(state.db['chan'], "Pause between questions has been changed to %s." % (state.db['questionpause']))
+ except:
+ bot.msg(user, "Failed to set questionpause.")
+
+@lib.hook(glevel=1, needchan=False)
+def findq(bot, user, chan, realtarget, *args):
+ if len(args) == 0:
+ bot.msg(user, "You need to specify a search string.")
+ return
+
+ searcher = re.compile(' '.join(args))
+ matches = [str(i) for i in range(len(state.db['questions'])) if searcher.search(state.db['questions'][i][0]) is not None]
+ if len(matches) > 25:
+ bot.msg(user, "Too many matches! (>25)")
+ elif len(matches) > 1:
+ bot.msg(user, "Multiple matches: %s" % (', '.join(matches)))
+ elif len(matches) == 1:
+ bot.msg(user, "One match: %s" % (matches[0]))
+ else:
+ bot.msg(user, "No match.")
+
+@lib.hook(('delq', 'deleteq'), glevel=lib.STAFF, needchan=False)
+def delq(bot, user, chan, realtarget, *args):
+ try:
+ backup = state.db['questions'][int(args[0])]
+ del state.db['questions'][int(args[0])]
+ bot.msg(user, "Deleted %s*%s" % (backup[0], backup[1]))
+ except:
+ bot.msg(user, "Couldn't delete that question.")
+
+@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)")