aboutsummaryrefslogtreecommitdiffstats
path: root/slack
diff options
context:
space:
mode:
Diffstat (limited to 'slack')
-rw-r--r--slack/slack_buffer.py6
-rw-r--r--slack/slack_conversation.py5
-rw-r--r--slack/slack_message.py11
-rw-r--r--slack/slack_workspace.py21
4 files changed, 43 insertions, 0 deletions
diff --git a/slack/slack_buffer.py b/slack/slack_buffer.py
index 2fe144d..e2cdeac 100644
--- a/slack/slack_buffer.py
+++ b/slack/slack_buffer.py
@@ -259,6 +259,12 @@ class SlackBuffer(ABC):
if backlog:
weechat.buffer_set(self.buffer_pointer, "unread", "")
+ def set_unread_and_hotlist(self):
+ if self.buffer_pointer:
+ # TODO: Move unread marker to correct position according to last_read for WeeChat >= 4.0.0
+ weechat.buffer_set(self.buffer_pointer, "unread", "")
+ weechat.buffer_set(self.buffer_pointer, "hotlist", "-1")
+
def _buffer_input_cb(self, data: str, buffer: str, input_data: str) -> int:
weechat.prnt(buffer, "Text: %s" % input_data)
return weechat.WEECHAT_RC_OK
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py
index cb5e53f..e290933 100644
--- a/slack/slack_conversation.py
+++ b/slack/slack_conversation.py
@@ -156,6 +156,11 @@ class SlackConversation(SlackBuffer):
def last_read(self) -> SlackTs:
return SlackTs(self._info["last_read"])
+ @last_read.setter
+ def last_read(self, value: SlackTs):
+ self._info["last_read"] = value
+ self.set_unread_and_hotlist()
+
async def sort_key(self) -> str:
type_sort_key = {
"channel": 0,
diff --git a/slack/slack_message.py b/slack/slack_message.py
index 968c1f7..6294282 100644
--- a/slack/slack_message.py
+++ b/slack/slack_message.py
@@ -201,6 +201,17 @@ class SlackMessage:
else:
return SlackTs("0.0")
+ @last_read.setter
+ def last_read(self, value: SlackTs):
+ if "last_read" in self._message_json:
+ self._message_json["last_read"] = value
+ if self.thread_buffer:
+ self.thread_buffer.set_unread_and_hotlist()
+ else:
+ raise SlackError(
+ self.workspace, "Cannot set last_read on a message without last_read"
+ )
+
@property
def is_bot_message(self) -> bool:
return (
diff --git a/slack/slack_workspace.py b/slack/slack_workspace.py
index dcf0279..59ac415 100644
--- a/slack/slack_workspace.py
+++ b/slack/slack_workspace.py
@@ -320,6 +320,11 @@ class SlackWorkspace:
return
elif data["type"] == "reaction_added" or data["type"] == "reaction_removed":
channel_id = data["item"]["channel"]
+ elif (
+ data["type"] == "thread_marked"
+ and data["subscription"]["type"] == "thread"
+ ):
+ channel_id = data["subscription"]["channel"]
elif data["type"] == "sh_room_join" or data["type"] == "sh_room_update":
channel_id = data["huddle"]["channel_id"]
elif "channel" in data and type(data["channel"]) == str:
@@ -356,6 +361,22 @@ class SlackWorkspace:
await channel.reaction_remove(
SlackTs(data["item"]["ts"]), data["reaction"], data["user"]
)
+ elif (
+ data["type"] == "channel_marked"
+ or data["type"] == "group_marked"
+ or data["type"] == "mpim_marked"
+ or data["type"] == "im_marked"
+ ):
+ channel.last_read = SlackTs(data["ts"])
+ elif (
+ data["type"] == "thread_marked"
+ and data["subscription"]["type"] == "thread"
+ ):
+ message = channel.messages.get(
+ SlackTs(data["subscription"]["thread_ts"])
+ )
+ if message:
+ message.last_read = SlackTs(data["subscription"]["last_read"])
elif data["type"] == "sh_room_join" or data["type"] == "sh_room_update":
await channel.update_message_room(data)
elif data["type"] == "user_typing":