aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_conversation.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2024-01-11 00:29:51 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:55 +0100
commit1989a394e96df843a1e5d852e9706cafcf6c0945 (patch)
tree170f758cef926dd429fecef49eb9311fa0435224 /slack/slack_conversation.py
parentfa0001661c400327c4fdebeb226a08bcdb1a5fd1 (diff)
downloadwee-slack-1989a394e96df843a1e5d852e9706cafcf6c0945.tar.gz
Set buffer_pointer to None when buffer doesn't exist
This enforces us to check that buffer_pointer is set, so we don't accidentally operate on the core buffer, which is what is done when buffer_pointer is an empty string.
Diffstat (limited to 'slack/slack_conversation.py')
-rw-r--r--slack/slack_conversation.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py
index 8b2bb67..2c95f4c 100644
--- a/slack/slack_conversation.py
+++ b/slack/slack_conversation.py
@@ -555,7 +555,7 @@ class SlackConversation(SlackBuffer):
self.nicklist_add_nick(user.nick)
def nicklist_add_nick(self, nick: Nick):
- if nick in self._nicklist or self.type == "im":
+ if nick in self._nicklist or self.type == "im" or self.buffer_pointer is None:
return
# TODO: weechat.color.nicklist_away
@@ -568,25 +568,27 @@ class SlackConversation(SlackBuffer):
self._nicklist[nick] = nick_pointer
def nicklist_remove_nick(self, nick: Nick):
- if self.type == "im":
+ if self.type == "im" or self.buffer_pointer is None:
return
nick_pointer = self._nicklist.pop(nick)
weechat.nicklist_remove_nick(self.buffer_pointer, nick_pointer)
def display_thread_replies(self) -> bool:
- buffer_value = weechat.buffer_get_string(
- self.buffer_pointer, "localvar_display_thread_replies_in_channel"
- )
- if buffer_value:
- return bool(weechat.config_string_to_boolean(buffer_value))
+ if self.buffer_pointer is not None:
+ buffer_value = weechat.buffer_get_string(
+ self.buffer_pointer, "localvar_display_thread_replies_in_channel"
+ )
+ if buffer_value:
+ return bool(weechat.config_string_to_boolean(buffer_value))
return shared.config.look.display_thread_replies_in_channel.value
def display_reaction_nicks(self) -> bool:
- buffer_value = weechat.buffer_get_string(
- self.buffer_pointer, "localvar_display_reaction_nicks"
- )
- if buffer_value:
- return bool(weechat.config_string_to_boolean(buffer_value))
+ if self.buffer_pointer is not None:
+ buffer_value = weechat.buffer_get_string(
+ self.buffer_pointer, "localvar_display_reaction_nicks"
+ )
+ if buffer_value:
+ return bool(weechat.config_string_to_boolean(buffer_value))
return shared.config.look.display_reaction_nicks.value
def should_display_message(self, message: SlackMessage) -> bool:
@@ -605,7 +607,7 @@ class SlackConversation(SlackBuffer):
self.history_pending_messages.append(message)
elif self.last_printed_ts is not None:
await self.print_message(message)
- else:
+ elif self.buffer_pointer is not None:
weechat.buffer_set(
self.buffer_pointer, "hotlist", message.priority.value
)