+@lib.hook('badq', needchan=False)
+@lib.argsGE(2)
+def cmd_badq(bot, user, chan, realtarget, *args):
+ qid = int(args[0])
+ reason = ' '.join(args[1:])
+ state.db['badqs'].append([qid, reason])
+ bot.msg(user, "Reported bad question #%d" % (qid))
+
+@lib.hook('badqs', glevel=lib.STAFF, needchan=False)
+def cmd_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: Q%d: %s" % (i, report[0], report[1]))
+ question = state.db['questions'][int(report[0])]
+ bot.msg(user, "- Question is: %s" % (question[0]))
+ bot.msg(user, "- Answer is: %s" % (question[1]))
+ except Exception as e:
+ bot.msg(user, "- Exception: %r" % (e))
+
+@lib.hook('clearbadqs', glevel=lib.STAFF, needchan=False)
+def cmd_clearbadqs(bot, user, chan, realtarget, *args):
+ state.db['badqs'] = []
+ bot.msg(user, "Cleared reports.")
+
+@lib.hook('delbadq', glevel=lib.STAFF, needchan=False)
+@lib.argsEQ(1)
+def cmd_delbadq(bot, user, chan, realtarget, *args):
+ qid = int(args[0])
+ del state.db['badqs'][qid]
+ bot.msg(user, "Removed report #%d" % (qid))
+