diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-02-03 01:27:31 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | 4de39f91d9d8942816b8967a115010c466b8f252 (patch) | |
tree | e019d0f6437f131ce3192991b17ef2263ee442e8 /slack/slack_conversation.py | |
parent | 684e7d701a4eb21c3b95954c3ca2e38d78ee451c (diff) | |
download | wee-slack-4de39f91d9d8942816b8967a115010c466b8f252.tar.gz |
Add messages received over rtm to channels
Diffstat (limited to 'slack/slack_conversation.py')
-rw-r--r-- | slack/slack_conversation.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index b65ad98..e72e293 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -1,6 +1,7 @@ from __future__ import annotations import time +from collections import OrderedDict from contextlib import contextmanager from typing import TYPE_CHECKING, List, Optional @@ -38,6 +39,7 @@ class SlackConversation: self.workspace = workspace self._info = info self._members: Optional[List[str]] = None + self._messages: OrderedDict[str, SlackMessage] = OrderedDict() # TODO: buffer_pointer may be accessed by buffer_switch before it's initialized self.buffer_pointer: str = "" self.is_loading = False @@ -150,6 +152,8 @@ class SlackConversation: start = time.time() messages = [SlackMessage(self, message) for message in history["messages"]] + for message in messages: + self._messages[message.ts] = message sender_user_ids = [m.sender_user_id for m in messages if m.sender_user_id] await self.workspace.users.initialize_items(sender_user_ids) @@ -165,6 +169,11 @@ class SlackConversation: self.history_filled = True self.history_pending = False + async def add_message(self, message: SlackMessage): + self._messages[message.ts] = message + message_rendered = await message.render_message() + weechat.prnt(self.buffer_pointer, message_rendered) + 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 |