- state.db['questions'].append({'question':question,'answer':answer})
- bot.msg(user, "Done. Question is #%s" % (len(state.db['questions'])-1))
-
-
-@lib.hook('triviahelp', needchan=False)
-def cmd_triviahelp(bot, user, chan, realtarget, *args):
- bot.msg(user, "START")
- bot.msg(user, "TOP10")
- bot.msg(user, "POINTS [<user>]")
- bot.msg(user, "RANK [<user>]")
- if bot.parent.channel(state.db['chan']).levelof(user.auth) >= lib.KNOWN:
- bot.msg(user, "SKIP (>=KNOWN )")
- bot.msg(user, "STOP (>=KNOWN )")
- bot.msg(user, "FINDQ <question> (>=KNOWN )")
- if bot.parent.channel(state.db['chan']).levelof(user.auth) >= lib.OP:
- bot.msg(user, "GIVE <user> [<points>] (>=OP )")
- bot.msg(user, "SETNEXT <q>*<a> (>=OP )")
- bot.msg(user, "ADDQ <q>*<a> (>=OP )")
- bot.msg(user, "DELETEQ <q>*<a> (>=OP ) [aka DELQ]")
- if bot.parent.channel(state.db['chan']).levelof(user.auth) >= lib.MASTER:
- bot.msg(user, "SETTARGET <points> (>=MASTER)")
- bot.msg(user, "MAXMISSED <questions> (>=MASTER)")
- bot.msg(user, "HINTTIMER <float seconds> (>=MASTER)")
- bot.msg(user, "HINTNUM <hints> (>=MASTER)")
+ questions.append([question, answer])
+ bot.msg(user, "Done. Question is #%s" % (len(questions)-1))
+
+@lib.hook(glevel=1, needchan=False)
+@lib.help("<category>", "change category")
+def setcat(bot, user, chan, realtarget, *args):
+ category = args[0].lower()
+ if category in state.db['questions']:
+ state.db['category'] = category
+ state.questions = state.db['questions'][category]
+ bot.msg(user, "Changed category to %s" % (category))
+ else:
+ bot.msg(user, "That category doesn't exist.")
+
+@lib.hook(needchan=False)
+@lib.help(None, "list categories")
+def listcats(bot, user, chan, realtarget, *args):
+ cats = ["%s (%d)" % (c, len(state.db['questions'][c])) for c in state.db['questions'].keys()]
+ bot.msg(user, "Categories: %s" % (', '.join(cats)))
+
+@lib.hook(glevel=lib.STAFF, needchan=False)
+@lib.help("<category>", "adds an empty category")
+def addcat(bot, user, chan, realtarget, *args):
+ category = args[0].lower()
+ if category not in state.db['questions']:
+ state.db['questions'][category] = []
+ bot.msg(user, "Added category %s" % (category))
+ else:
+ bot.msg(user, "Category already exists.")
+
+@lib.hook(glevel=lib.MANAGER, needchan=False)
+@lib.help("<category>", "deletes an entire category")
+def delcat(bot, user, chan, realtarget, *args):
+ category = args[0].lower()
+ if category == state.db['category']:
+ bot.msg(user, "Category currently in use!")
+ elif category in state.db['questions']:
+ length = len(state.db['questions'][category])
+ del state.db['questions'][category]
+ bot.msg(user, "Deleted category %s (%d questions)" % (category, length))
+ else:
+ bot.msg(user, "Category does not exist.")
+
+@lib.hook(needchan=False)
+def triviahelp(bot, user, chan, realtarget, *args):
+ bot.slowmsg(user, "START")
+ bot.slowmsg(user, "TOP10")
+ bot.slowmsg(user, "POINTS [<user>]")
+ bot.slowmsg(user, "RANK [<user>]")
+ bot.slowmsg(user, "BADQ <reason> (include info to identify question)")
+ if user.glevel >= 1:
+ bot.slowmsg(user, "SKIP (KNOWN)")
+ bot.slowmsg(user, "STOP (KNOWN)")
+ bot.slowmsg(user, "FINDQ <full question> (KNOWN)")
+ bot.slowmsg(user, "FINDQRE <regex> (KNOWN)")
+ bot.slowmsg(user, "SETNEXTID <qid> (KNOWN)")
+ if user.glevel >= lib.STAFF:
+ bot.slowmsg(user, "GIVE <user> [<points>] (STAFF)")
+ bot.slowmsg(user, "SETNEXT <q>*<a> (STAFF)")
+ bot.slowmsg(user, "ADDQ <q>*<a> (STAFF)")
+ bot.slowmsg(user, "DELQ <q>*<a> (STAFF) [aka DELETEQ]")
+ bot.slowmsg(user, "SHOWQ <qid> (STAFF)")
+ bot.slowmsg(user, "BADQS (STAFF)")
+ bot.slowmsg(user, "CLEARBADQS (STAFF)")
+ bot.slowmsg(user, "DELBADQ <reportid> (STAFF)")
+ if user.glevel >= lib.ADMIN:
+ bot.slowmsg(user, "SETTARGET <points> (ADMIN)")
+ bot.slowmsg(user, "MAXMISSED <questions> (ADMIN)")
+ bot.slowmsg(user, "HINTTIMER <float seconds> (ADMIN)")
+ bot.slowmsg(user, "HINTNUM <hints> (ADMIN)")
+ bot.slowmsg(user, "QUESTIONPAUSE <float seconds> (ADMIN)")