Add some time delays, minor output improvements.
This commit is contained in:
parent
d76ec8a3b6
commit
bf2da99ce6
1 changed files with 15 additions and 6 deletions
21
lolbot.py
21
lolbot.py
|
|
@ -213,18 +213,21 @@ class LolBot(SingleServerIRCBot):
|
|||
self.quiz += 1
|
||||
self.question = random.choice(self.qb)
|
||||
print(str(self.question.question))
|
||||
self.connection.notice(self.channel, str(self.question.question))
|
||||
self.connection.notice(self.channel, "Question %s: %s" % (self.quiz, str(self.question.question)))
|
||||
|
||||
def quiz_award_points(self, nick):
|
||||
score = "%s point" % self.question.score
|
||||
if self.question.score != 1:
|
||||
score += "s"
|
||||
|
||||
self.connection.notice(self.channel, 'Correct! The answer was %s. %s scores %s.' % (self.question.answer, nick, score))
|
||||
if nick not in self.quiz_scores.keys():
|
||||
self.quiz_scores[nick] = 0
|
||||
self.quiz_scores[nick] += self.question.score
|
||||
|
||||
score = "%s point" % self.quiz_scores[nick]
|
||||
if self.quiz_scores[nick] != 1:
|
||||
score += "s"
|
||||
|
||||
self.connection.notice(self.channel, 'Correct! The answer was %s.' % self.question.answer)
|
||||
time.sleep(1)
|
||||
self.connection.notice(self.channel, '%s is on %s.' % (nick, score))
|
||||
|
||||
def quiz_check_win(self, nick):
|
||||
if self.quiz_scores[nick] == 10:
|
||||
self.connection.notice(self.channel, '%s wins with 10 points!' % nick)
|
||||
|
|
@ -232,6 +235,10 @@ class LolBot(SingleServerIRCBot):
|
|||
self.stop_quiz()
|
||||
|
||||
def quiz_scoreboard(self):
|
||||
if not self.quiz:
|
||||
self.connection.notice(self.channel, 'Quiz not running.')
|
||||
return
|
||||
|
||||
self.connection.notice(self.channel, 'Scoreboard:')
|
||||
for nick in self.quiz_scores.keys():
|
||||
score = "%s point" % self.quiz_scores[nick]
|
||||
|
|
@ -249,6 +256,7 @@ class LolBot(SingleServerIRCBot):
|
|||
# see if anyone answered correctly.
|
||||
if self.question.attempt(message):
|
||||
self.quiz_award_points(nick)
|
||||
time.sleep(1)
|
||||
self.quiz_check_win(nick)
|
||||
|
||||
# if nobody has won, carry on
|
||||
|
|
@ -258,6 +266,7 @@ class LolBot(SingleServerIRCBot):
|
|||
if self.quiz % 10 == 0:
|
||||
self.quiz_scoreboard()
|
||||
|
||||
time.sleep(1)
|
||||
self.quiz_get_next()
|
||||
|
||||
def do_command(self, e, cmd):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue