make handles case insensitive when it comes to assigning karma
remove one of the responses to bot snacks
This commit is contained in:
parent
eb49ac41c5
commit
d57848d4e1
1 changed files with 5 additions and 6 deletions
|
@ -20,7 +20,6 @@ def botsnack_cb(room, event):
|
||||||
"That makes me happy",
|
"That makes me happy",
|
||||||
"How kind!",
|
"How kind!",
|
||||||
"Sweet.",
|
"Sweet.",
|
||||||
"Sorry, but I can't handle more right now.",
|
|
||||||
"*burp*",
|
"*burp*",
|
||||||
"Ah.. Hiccup!"
|
"Ah.. Hiccup!"
|
||||||
]
|
]
|
||||||
|
@ -43,7 +42,7 @@ def karma_cb(room, event):
|
||||||
members = room.get_joined_members()
|
members = room.get_joined_members()
|
||||||
msender = re.search('@([\w]+_)?([^:]+)', event['sender'])
|
msender = re.search('@([\w]+_)?([^:]+)', event['sender'])
|
||||||
sender = msender.group(2)
|
sender = msender.group(2)
|
||||||
tokens = re.search("([\w]+)(\-\-|\+\+)", event['content']['body'])
|
tokens = re.search("([\w]+)\s?(\-\-|\+\+)", event['content']['body'])
|
||||||
handle = tokens.group(1)
|
handle = tokens.group(1)
|
||||||
sign = tokens.group(2)
|
sign = tokens.group(2)
|
||||||
reply = ""
|
reply = ""
|
||||||
|
@ -84,11 +83,11 @@ def karma_cb(room, event):
|
||||||
def _set_karma(room, room_id, handle, sign):
|
def _set_karma(room, room_id, handle, sign):
|
||||||
|
|
||||||
if sign == '++':
|
if sign == '++':
|
||||||
rs.incr("partybot:k_" + room_id + "@" + handle)
|
rs.incr("partybot:k_" + room_id + "@" + handle.lower())
|
||||||
elif sign == '--':
|
elif sign == '--':
|
||||||
rs.decr("partybot:k_" + room_id + "@" + handle)
|
rs.decr("partybot:k_" + room_id + "@" + handle.lower())
|
||||||
|
|
||||||
k = int(rs.get("partybot:k_" + room_id + "@" + handle))
|
k = int(rs.get("partybot:k_" + room_id + "@" + handle.lower()))
|
||||||
reply = handle + " has " + str(k) + " karma in this channel."
|
reply = handle + " has " + str(k) + " karma in this channel."
|
||||||
room.send_notice(reply)
|
room.send_notice(reply)
|
||||||
|
|
||||||
|
@ -115,7 +114,7 @@ if __name__ == "__main__":
|
||||||
rs = redis.StrictRedis()
|
rs = redis.StrictRedis()
|
||||||
bot = MatrixBotAPI(config['username'], config['password'], config['url'])
|
bot = MatrixBotAPI(config['username'], config['password'], config['url'])
|
||||||
|
|
||||||
bot.add_handler(MRegexHandler("([\w]+)(\-\-|\+\+)", karma_cb))
|
bot.add_handler(MRegexHandler("([\w]+)\s?(\-\-|\+\+)", karma_cb))
|
||||||
bot.add_handler(MCommandHandler("karma", show_karma_cb))
|
bot.add_handler(MCommandHandler("karma", show_karma_cb))
|
||||||
bot.add_handler(MCommandHandler("botsnack", botsnack_cb))
|
bot.add_handler(MCommandHandler("botsnack", botsnack_cb))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue