+@lib.hook(needchan=False)
+@lib.help("<reason>", "reports a bad question to the admins")
+@lib.argsGE(1)
+def badq(bot, user, chan, realtarget, *args):
+ lastqid = state.lastqid
+ curqid = state.curqid
+
+ reason = ' '.join(args)
+ state.db['badqs'].append([state.db['category'], lastqid, curqid, reason])
+ bot.msg(user, "Reported bad question.")
+
+@lib.hook(glevel=lib.STAFF, needchan=False)
+@lib.help(None, "shows a list of BADQ reports")
+def badqs(bot, user, chan, realtarget, *args):
+ if len(state.db['badqs']) == 0:
+ bot.msg(user, "No reports.")
+
+ for i in range(len(state.db['badqs'])):
+ try:
+ report = state.db['badqs'][i]
+ bot.msg(user, "Report #%d: Cat=%s LastQ=%r CurQ=%r: %s" % (i, report[0], report[1], report[2], report[3]))
+ try: lq = state.db['questions'][report[0]][int(report[1])]
+ except Exception as e: lq = (None,None)
+ try: cq = state.db['questions'][report[0]][int(report[2])]
+ except Exception as e: cq = (None, None)
+ bot.msg(user, "- Last: %s*%s" % (lq[0], lq[1]))
+ bot.msg(user, "- Curr: %s*%s" % (cq[0], cq[1]))
+ except Exception as e:
+ bot.msg(user, "- Exception: %r" % (e))
+
+@lib.hook(glevel=lib.STAFF, needchan=False)
+@lib.hook(None, "clears list of BADQ reports")
+def clearbadqs(bot, user, chan, realtarget, *args):
+ state.db['badqs'] = []
+ bot.msg(user, "Cleared reports.")
+
+@lib.hook(glevel=lib.STAFF, needchan=False)
+@lib.hook("<badqid>", "removes a BADQ report")
+@lib.argsEQ(1)
+def delbadq(bot, user, chan, realtarget, *args):
+ try:
+ qid = int(args[0])
+ del state.db['badqs'][qid]
+ bot.msg(user, "Removed report #%d" % (qid))
+ except:
+ bot.msg(user, "Failed!")
+
+@lib.hook(needchan=False)
+@lib.help("[<user>]", "shows you or someone else's rank")
+def rank(bot, user, chan, realtarget, *args):
+ if chan is not None and realtarget == chan.name: replyto = chan