aboutsummaryrefslogtreecommitdiffstats
path: root/slack
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-10-22 14:43:36 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit0cb37109508d3828570c15f8ec68d65b11ff1ba1 (patch)
treeb2518b82145a35b336c231106aa5352e32ce6395 /slack
parent9d02396291e6d687a8c743799b4266e49bcc794a (diff)
downloadwee-slack-0cb37109508d3828570c15f8ec68d65b11ff1ba1.tar.gz
Support completion of all workspace nicks
Diffstat (limited to 'slack')
-rw-r--r--slack/commands.py21
-rw-r--r--slack/task.py3
2 files changed, 21 insertions, 3 deletions
diff --git a/slack/commands.py b/slack/commands.py
index ce7ea4f..2d7cb09 100644
--- a/slack/commands.py
+++ b/slack/commands.py
@@ -1,6 +1,7 @@
from __future__ import annotations
import json
+import locale
import pprint
import re
from dataclasses import dataclass
@@ -492,12 +493,26 @@ def completion_nicks_cb(
if slack_buffer is None:
return weechat.WEECHAT_RC_OK
- for user in slack_buffer.members:
+ buffer_nicks = set(f"@{user.nick(only_nick=True)}" for user in slack_buffer.members)
+ for nick in sorted(buffer_nicks, key=locale.strxfrm):
weechat.completion_list_add(
completion,
- f"@{user.nick(only_nick=True)}",
+ nick,
1,
- weechat.WEECHAT_LIST_POS_SORT,
+ weechat.WEECHAT_LIST_POS_END,
+ )
+
+ workspace_nicks = set(
+ f"@{user.result().nick(only_nick=True)}"
+ for user in slack_buffer.workspace.users.values()
+ if user.done_with_result()
+ )
+ for nick in sorted(workspace_nicks - buffer_nicks, key=locale.strxfrm):
+ weechat.completion_list_add(
+ completion,
+ nick,
+ 1,
+ weechat.WEECHAT_LIST_POS_END,
)
return weechat.WEECHAT_RC_OK
diff --git a/slack/task.py b/slack/task.py
index d48af4a..f6a373b 100644
--- a/slack/task.py
+++ b/slack/task.py
@@ -109,6 +109,9 @@ class Future(Awaitable[T]):
def done(self):
return self._state != "PENDING"
+ def done_with_result(self):
+ return self._state == "FINISHED" and self._exception is None
+
def cancelled(self):
return self._state == "CANCELLED"