aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2018-08-16 23:08:24 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2018-08-17 00:08:56 +0200
commit68966be9a711bb6e8dc164e921563de648fa84da (patch)
tree12b9d9f0f385017123bd5d9c71e14e3e3a13297a /wee_slack.py
parent21eeabe0cc661885624c8fcba102a2170f8ed058 (diff)
downloadwee-slack-68966be9a711bb6e8dc164e921563de648fa84da.tar.gz
Don't process message again if it already exists
The API has started to send both responses for sent messages as well as message events for the same messages. Previously, we would only get message events for messages from other clients. For the messages we send ourselves we would just get responses, and no message events. This caused wee-slack to print own messages twice, once for the response and once for the message event. To prevent this, check if we already have a message for the ts, and if we do, ignore the new message. I don't want to rely on only the message events and ignore the responses, because this change has rolled out gradually, so not all users might get message events for own messages yet. Additionally, the docs are not clear on what the behavior should be. Fixes #606
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index f4e9b88..6b05062 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2478,6 +2478,10 @@ def process_pong(message_json, eventrouter, **kwargs):
def process_message(message_json, eventrouter, store=True, **kwargs):
channel = kwargs["channel"]
team = kwargs["team"]
+
+ if SlackTS(message_json["ts"]) in channel.messages:
+ return
+
# try:
# send these subtype messages elsewhere
known_subtypes = [