'author': 'Erebus Team',
'license': 'public domain',
'compatible': [0],
- 'depends': ['userinfo'],
- 'softdeps': ['help'],
+ 'depends': [],
+ 'softdeps': ['help','userinfo'],
}
# preamble
return 0
def country(num, default="??"):
- return lib.mod('userinfo').get(person(num), 'country', default=default).upper()
+ try:
+ return lib.mod('userinfo').get(person(num), 'country', default=default).upper()
+ except KeyError:
+ return default.upper()
class MyTimer(timerbase):
def __init__(self, *args, **kwargs):
class TriviaState(object):
def __init__(self, parent=None, pointvote=False):
+ self.streak = 0
+ self.streak_holder = None
if parent is not None:
self.gotParent(parent, pointvote)
except Exception as e:
msg("DERP! %r" % (e))
- self.db['lastwinner'] = winner
- self.db['lastwon'] = time.time()
-
if self.db['hofpath'] is not None and self.db['hofpath'] != '':
self.writeHof()
+ self.db['lastwinner'] = winner
+ self.db['lastwon'] = time.time()
+
self.db['users'] = {}
self.db['ranks'] = []
self.savedb()
if self.gameover == True:
return self.doGameOver()
if qskipped:
+ self.streak = 0
+ self.streak_holder = None
self.getchan().fastmsg("\00304Fail! The correct answer was: %s" % (self.hintanswer))
self.missedquestions += 1
else:
line = ' '.join([str(arg) for arg in args])
if state.checkanswer(line):
state.curq = None
- if state.hintanswer.lower() == line.lower():
- bot.fastmsg(chan, "\00312%s\003 has it! The answer was \00312%s\003. New score: %d. Rank: %d. Target: %s %s" % (user, line, state.addpoint(user), state.rank(user), state.targetuser(user), state.targetpoints(user)))
+
+ if state.streak_holder == user:
+ state.streak += 1
else:
- bot.fastmsg(chan, "\00312%s\003 has it! The answer was \00312%s\003 (hinted answer: %s). New score: %d. Rank: %d. Target: %s%s" % (user, line, state.hintanswer, state.addpoint(user), state.rank(user), state.targetuser(user), state.targetpoints(user)))
+ if state.streak >= 3:
+ bot.fastmsg(chan, "\00312%s\003 broke \00304%s\003's streak of \00307%d\003!" % (user, state.streak_holder, state.streak))
+ state.streak_holder = user
+ state.streak = 1
+
+ response = "\00312%s\003 has it! The answer was \00312%s\003" % (user, line)
+ if state.hintanswer.lower() != line.lower():
+ response += " (hinted answer: %s)" % (state.hintanswer)
+ response += ". New score: %d. Rank: %d. Target: %s %s" % (state.addpoint(user), state.rank(user), state.targetuser(user), state.targetpoints(user))
+ bot.fastmsg(chan, response)
+
+ if state.streak >= 3:
+ bot.msg(chan, "\00312%s\003 is on a streak! \00307%d\003 answers correct in a row!" % (user, state.streak))
+
if state.hintsgiven == 0:
bot.msg(chan, "\00312%s\003 got an extra point for getting it before the hints! New score: %d." % (user, state.addpoint(user)))
+
state.nextquestion()
@lib.hook(glevel=1, needchan=False, wantchan=True)
bot.msg(user, "Error: no such QID.")
return
state.nextqid = qid
- bot.msg(user, "Done. Next question is %d: %s" % (qid, state.questions[qid][0]))
+ bot.msg(user, "Done. Next question is %d: %s" % (qid, state.questions[qid][0]), truncate=True)
@lib.hook(glevel=lib.STAFF, needchan=False)
@lib.help("<q>*<a>", "sets next question to one not in database")
bot.msg(user, "Failed to set questionpause.")
@lib.hook(glevel=1, needchan=False)
-@lib.help("<full question>", "finds a qid given a complete question")
+@lib.help("[@category] <full question>", "finds a qid given a complete question")
+@lib.argsGE(1)
def findq(bot, user, chan, realtarget, *args):
args = list(args)
if args[0].startswith("@"):
@lib.hook(glevel=1, needchan=False)
@lib.help("[@<category>] <regex>", "finds a qid given a regex or partial question")
+@lib.argsGE(1)
def findqre(bot, user, chan, realtarget, *args):
args = list(args)
if args[0].startswith("@"):
except:
bot.msg(user, "ID not valid.")
return
- bot.msg(user, "%s: %s*%s" % (qid, q[0], q[1]))
+ bot.msg(user, "%s: %s*%s" % (qid, q[0], q[1]), True)
@lib.hook(('delq', 'deleteq'), glevel=lib.STAFF, needchan=False)
@lib.help("[@<category>] <qid>", "removes a question from the database")
try:
backup = questions[int(args[0])]
del questions[int(args[0])]
- bot.msg(user, "Deleted %s*%s" % (backup[0], backup[1]))
- except:
+ bot.msg(user, "Deleted %s*%s" % (backup[0], backup[1]), True)
+ except Exception as e:
bot.msg(user, "Couldn't delete that question. %r" % (e))
@lib.hook(glevel=lib.STAFF, needchan=False)