From d575b847aab06c54f1f38b79da74ad24d9b97ea0 Mon Sep 17 00:00:00 2001 From: Ryan Huber Date: Mon, 6 Feb 2017 07:25:11 -0800 Subject: check for message before modifying --- wee_slack.py | 12 ++++++++---- 1 file 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)) -- cgit