diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-09 23:35:09 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 13:01:40 +0100 |
commit | 312553ce2f33a120bee07b356d92ce848ab4ce86 (patch) | |
tree | cff37dbaab34b55b03ce29389123164e241bf6b2 /slack/slack_conversation.py | |
parent | 65c9b622572038a634bee3897b2e97989a050780 (diff) | |
download | wee-slack-312553ce2f33a120bee07b356d92ce848ab4ce86.tar.gz |
Don't print the same message multiple times
When joining a channel you seem to get the last messages for it over the
WebSocket. When joining a channel you've parted and you still have the
buffer for open, those messages will already be in the buffer, so we
have to make sure their not printed multiple times.
I've also been told that messages can appear multiple times in the
reconnect brach, which this should fix too.
Diffstat (limited to 'slack/slack_conversation.py')
-rw-r--r-- | slack/slack_conversation.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index ffea7c6..9085397 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -723,13 +723,16 @@ class SlackConversation(SlackBuffer): await thread_message.thread_buffer.open_buffer(switch) async def print_message(self, message: SlackMessage): - await super().print_message(message) + did_print = await super().print_message(message) - nick = await message.nick() - if message.subtype in ["channel_leave", "group_leave"]: - self.nicklist_remove_nick(nick) - else: - self.nicklist_add_nick(nick) + if did_print: + nick = await message.nick() + if message.subtype in ["channel_leave", "group_leave"]: + self.nicklist_remove_nick(nick) + else: + self.nicklist_add_nick(nick) + + return did_print async def mark_read(self): if not self._is_joined: |