diff options
author | Ryan Huber <rhuber@gmail.com> | 2015-07-18 09:30:54 -0400 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2015-07-18 09:30:54 -0400 |
commit | e7a38d2157511665ef11a56d3c2284c05abc7b1f (patch) | |
tree | 03acd008ab8dcfb82adc34dbcecaaaf8bda35efa | |
parent | 4ac04f58846b1e6a322a0d6c5a030bc9d71e804b (diff) | |
download | wee-slack-e7a38d2157511665ef11a56d3c2284c05abc7b1f.tar.gz |
demeter reaction stuff - dry up a bit
-rw-r--r-- | wee_slack.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/wee_slack.py b/wee_slack.py index 256c43b..2a4d421 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -637,6 +637,20 @@ class Channel(SlackThing): self.buffer_redraw() return True + def add_reaction(self, ts, reaction): + if self.has_message(ts): + message_index = self.messages.index(ts) + self.messages[message_index].add_reaction(reaction) + self.buffer_redraw() + return True + + def remove_reaction(self, ts, reaction): + if self.has_message(ts): + message_index = self.messages.index(ts) + self.messages[message_index].remove_reaction(reaction) + self.buffer_redraw() + return True + def change_previous_message(self, old, new): message = self.my_last_message() if new == "" and old == "": @@ -1256,19 +1270,11 @@ def process_error(message_json): def process_reaction_added(message_json): channel = channels.find(message_json["item"]["channel"]) - try: - message_index = channel.messages.index(message_json["item"]["ts"]) - channel.messages[message_index].add_reaction(message_json["reaction"]) - channel.buffer_redraw() - except: - pass - + channel.add_reaction(message_json["item"]["ts"], message_json["reaction"]) def process_reaction_removed(message_json): channel = channels.find(message_json["item"]["channel"]) - message_index = channel.messages.index(message_json["item"]["ts"]) - channel.messages[message_index].remove_reaction(message_json["reaction"]) - channel.buffer_redraw() + channel.remove_reaction(message_json["item"]["ts"], message_json["reaction"]) def create_reaction_string(reactions): if not isinstance(reactions, list): |