diff options
author | Ryan Huber <rhuber@gmail.com> | 2017-02-06 07:25:11 -0800 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2017-02-06 07:25:11 -0800 |
commit | d575b847aab06c54f1f38b79da74ad24d9b97ea0 (patch) | |
tree | 7a22b1200cbf702c1c69dbae317c5f85435f1b89 /wee_slack.py | |
parent | 1f3cbb910b9b7e245af912c9d7b23523aa30318e (diff) | |
download | wee-slack-d575b847aab06c54f1f38b79da74ad24d9b97ea0.tar.gz |
check for message before modifying
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py index 67a8635..6815ed1 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1945,8 +1945,10 @@ def process_reaction_added(message_json, eventrouter, **kwargs): if message_json["item"].get("type") == "message": ts = SlackTS(message_json['item']["ts"]) - channel.messages[ts].add_reaction(message_json["reaction"], message_json["user"]) - channel.change_message(ts) + message = channel.messages.get(ts, None) + if message: + message.add_reaction(message_json["reaction"], message_json["user"]) + channel.change_message(ts) else: dbg("reaction to item type not supported: " + str(message_json)) @@ -1955,8 +1957,10 @@ def process_reaction_removed(message_json, eventrouter, **kwargs): if message_json["item"].get("type") == "message": ts = SlackTS(message_json['item']["ts"]) - channel.messages[ts].remove_reaction(message_json["reaction"], message_json["user"]) - channel.change_message(ts) + message = channel.messages.get(ts, None) + if message: + message.remove_reaction(message_json["reaction"], message_json["user"]) + channel.change_message(ts) else: dbg("Reaction to item type not supported: " + str(message_json)) |