include rank in karma output
This commit is contained in:
parent
98f07105bc
commit
84ba3107f0
@ -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
|
||||
meta.pubmsg_needs_bot_prefix = false
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user