Mercurial > hg > q
changeset 14:83ffdc13237e draft
Add functionality for printing all time highscore
author | Alexander Berntsen <alexander@plaimi.net> |
---|---|
date | Mon, 15 Apr 2013 18:18:12 +0200 |
parents | 55ff080455fe |
children | 0135902ded03 |
files | q |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/q +++ b/q @@ -130,6 +130,8 @@ self.deop(name) elif msg.startswith('!score'): self.print_score() + elif msg.startswith('!hiscore'): + self.print_hiscore() # Unknown command. elif msg[0] == '!': self.msg(self.factory.channel if channel != self.nickname else @@ -302,6 +304,14 @@ (j, quizzer, points)) prev_points = points + def print_hiscore(self): + """Print the top five quizzers of all time.""" + self.dbcur.execute('SELECT * FROM hiscore ORDER by wins DESC LIMIT 5') + hiscore = self.dbcur.fetchall() + for i, (quizzer, wins) in enumerate(hiscore): + self.msg(self.factory.channel, '%d. %s: %d points' % + (i + 1, quizzer.encode('UTF-8'), wins)) + def set_topic(self): self.dbcur.execute('SELECT * FROM hiscore ORDER by wins DESC LIMIT 1') alltime = self.dbcur.fetchone()