diff options
author | Ryan Huber <rhuber@gmail.com> | 2015-05-18 15:11:31 -0700 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2015-05-18 15:11:31 -0700 |
commit | ffc6f3435f5be79943ad5fc5d5ebf5b8121a308a (patch) | |
tree | 8949b031dc133ab567e1ea58cbde736ab0e080d7 /wee_slack.py | |
parent | a52bfc86bafa2262d76b00d3280ea64912155ed3 (diff) | |
download | wee-slack-ffc6f3435f5be79943ad5fc5d5ebf5b8121a308a.tar.gz |
initial support for emoji reactions
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py index cd51444..6e2990b 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1167,6 +1167,28 @@ def process_error(message_json): # def process_message_changed(message_json): # process_message(message_json) +def process_reaction_added(message_json): + do_reaction(message_json) + +def process_reaction_removed(message_json): + do_reaction(message_json) + +def do_reaction(message_json): + message = message_json["item"]["message"] + if "reactions" in message: + append = create_reaction_string(message["reactions"]) + else: + append = "" + channel = channels.find(message_json["item"]["channel"]) + user = users.find(message_json["item"]["message"]["user"]) + channel.buffer_prnt_changed(user, message["text"], message["ts"], append) + +def create_reaction_string(reactions): + reaction_string = ' *** ' + for r in reactions: + reaction_string += ":{}:{} ".format(r["name"], r["count"]) + return reaction_string + def cache_message(message_json, from_me=False): global message_cache if from_me: |