include rank in karma output
This commit is contained in:
parent
98f07105bc
commit
84ba3107f0
@ -7,10 +7,10 @@ usermode = -x
|
|||||||
debug = true
|
debug = true
|
||||||
admin_userhost = bss@ayu.incorporeal.org
|
admin_userhost = bss@ayu.incorporeal.org
|
||||||
module_list = IrcAdmin
|
module_list = IrcAdmin
|
||||||
|
database = dr.botzo.data
|
||||||
|
|
||||||
[IrcAdmin]
|
[IrcAdmin]
|
||||||
autojoin = #bss
|
autojoin = #bss
|
||||||
|
|
||||||
[Karma]
|
[Karma]
|
||||||
meta.pubmsg_needs_bot_prefix = false
|
meta.pubmsg_needs_bot_prefix = false
|
||||||
karmafile = karma
|
|
@ -96,9 +96,6 @@ class Karma(Module):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
finally: conn.close()
|
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):
|
def handle_karma_query(self, connection, nick, userhost, replypath, what):
|
||||||
match = self.queryre.match(what)
|
match = self.queryre.match(what)
|
||||||
key = match.group(1)
|
key = match.group(1)
|
||||||
@ -112,8 +109,16 @@ class Karma(Module):
|
|||||||
WHERE key = :key
|
WHERE key = :key
|
||||||
'''
|
'''
|
||||||
value = conn.execute(query, {'key': key}).fetchone()
|
value = conn.execute(query, {'key': key}).fetchone()
|
||||||
|
|
||||||
if (value != None):
|
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()
|
finally: conn.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user