From 84ba3107f0115760f5bc30ae88c89f4580998277 Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Sun, 24 Oct 2010 14:48:26 -0500 Subject: [PATCH] include rank in karma output --- dr.botzo.cfg.example | 4 ++-- modules/Karma.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dr.botzo.cfg.example b/dr.botzo.cfg.example index 7bf599d..efa4417 100644 --- a/dr.botzo.cfg.example +++ b/dr.botzo.cfg.example @@ -7,10 +7,10 @@ usermode = -x debug = true admin_userhost = bss@ayu.incorporeal.org module_list = IrcAdmin +database = dr.botzo.data [IrcAdmin] autojoin = #bss [Karma] -meta.pubmsg_needs_bot_prefix = false -karmafile = karma \ No newline at end of file +meta.pubmsg_needs_bot_prefix = false \ No newline at end of file diff --git a/modules/Karma.py b/modules/Karma.py index 940f991..6c1d4ea 100755 --- a/modules/Karma.py +++ b/modules/Karma.py @@ -96,9 +96,6 @@ class Karma(Module): conn.commit() finally: conn.close() - reply = "karma change for '" + key + "' (" + str(value) + ") by " + nick - self.reply(connection, replypath, reply) - def handle_karma_query(self, connection, nick, userhost, replypath, what): match = self.queryre.match(what) key = match.group(1) @@ -112,8 +109,16 @@ class Karma(Module): WHERE key = :key ''' value = conn.execute(query, {'key': key}).fetchone() + if (value != None): - reply = '{nick}: {key} has {value[0]!s} points of karma'.format(nick=nick, key=key, value=value) + query = ''' + SELECT count(*) FROM karma_values WHERE value > :value + ''' + rank = conn.execute(query, {'value': value[0]}).fetchone() + rank = rank[0] + 1; + + reply = '{nick}: {key} has {value[0]!s} points of karma (rank {rank})'.format( + nick=nick, key=key, value=value, rank=rank) finally: conn.close()