aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_conversation.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-08-20 12:10:28 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commitb4c1ebeead35f84d50dee33a9bf6d314a84a3d86 (patch)
tree47e07e1c04d360168812d47f6dd3703eaa6456bd /slack/slack_conversation.py
parent4e38811c1a97ed4217b8cf38aa0f82816e9f8513 (diff)
downloadwee-slack-b4c1ebeead35f84d50dee33a9bf6d314a84a3d86.tar.gz
Support sending and receiving typing
This does not support globally showing typing from direct messages, like the old wee-slack did, because that's not supported by WeeChats typing plugin. It only shows typing in the current buffer.
Diffstat (limited to 'slack/slack_conversation.py')
-rw-r--r--slack/slack_conversation.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py
index fc53979..7c0e90f 100644
--- a/slack/slack_conversation.py
+++ b/slack/slack_conversation.py
@@ -46,6 +46,7 @@ class SlackConversation:
self._info = info
self._members: Optional[List[str]] = None
self._messages: OrderedDict[SlackTs, SlackMessage] = OrderedDict()
+ self._typing_self_last_sent = time.time()
# TODO: buffer_pointer may be accessed by buffer_switch before it's initialized
self.buffer_pointer: str = ""
self.is_loading = False
@@ -251,6 +252,32 @@ class SlackConversation:
self.buffer_pointer, "hotlist", str(message.priority.value)
)
+ if message.sender_user_id:
+ user = await self.workspace.users[message.sender_user_id]
+ weechat.hook_signal_send(
+ "typing_set_nick",
+ weechat.WEECHAT_HOOK_SIGNAL_STRING,
+ f"{self.buffer_pointer};off;{user.nick()}",
+ )
+
+ async def typing_add_user(self, user_id: str, thread_ts: Optional[str]):
+ if not shared.config.look.typing_status_nicks.value:
+ return
+
+ if not thread_ts:
+ user = await self.workspace.users[user_id]
+ weechat.hook_signal_send(
+ "typing_set_nick",
+ weechat.WEECHAT_HOOK_SIGNAL_STRING,
+ f"{self.buffer_pointer};typing;{user.nick()}",
+ )
+
+ def typing_update_self(self, typing_state: str):
+ now = time.time()
+ if now - 4 > self._typing_self_last_sent:
+ self._typing_self_last_sent = now
+ self.workspace.send_typing(self.id)
+
def print_message(self, message: SlackMessage, rendered: str):
weechat.prnt_date_tags(self.buffer_pointer, message.ts.major, "", rendered)