aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-10-29 22:16:19 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2018-11-04 01:52:24 +0100
commitc904061b1d6bdcc8792a39511ade26c6ad560dc7 (patch)
treeca91495f6e47ea369c8c9396a879aa80b6cb5678
parent9172af8b8bd501e43da928926505f39f61ce4736 (diff)
downloadwee-slack-c904061b1d6bdcc8792a39511ade26c6ad560dc7.tar.gz
Add open thread command with cursor
-rw-r--r--README.md2
-rw-r--r--wee_slack.py12
2 files changed, 12 insertions, 2 deletions
diff --git a/README.md b/README.md
index a87ee95..2014076 100644
--- a/README.md
+++ b/README.md
@@ -273,6 +273,7 @@ The cursor mode and mouse mode can be used to interact with older messages, for
In cursor mode, the `M` key achieves the same result (memo: the default for weechat is to paste the message with `m`, `M` simply copies the id).
In addition, `R` will prepare a `/reply id` and `D` will delete the message (provided it’s yours).
+`T` will open the thread associated to a message, equivalent to `/thread id`
Please see weechat’s documentation about [how to use the cursor mode](https://weechat.org/files/doc/stable/weechat_user.en.html#key_bindings_cursor_context) or [adapt the bindings](https://weechat.org/files/doc/stable/weechat_user.en.html#command_weechat_key) to your preference.
@@ -282,6 +283,7 @@ Default:
/key bindctxt cursor @chat(python.*.slack.com.*):M hsignal:slack_cursor_message
/key bindctxt cursor @chat(python.*.slack.com.*):D hsignal:slack_cursor_delete
/key bindctxt cursor @chat(python.*.slack.com.*):R hsignal:slack_cursor_reply
+/key bindctxt cursor @chat(python.*.slack.com.*):T hsignal:slack_cursor_thread
```
hsignals `slack_mouse` and `slack_cursor_message` currently have the same meaning but may be subject to evolutions.
diff --git a/wee_slack.py b/wee_slack.py
index cf5c3f0..77173f0 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3534,10 +3534,13 @@ def thread_command_callback(data, current_buffer, args):
args = args.split()
if args[0] == '/thread':
if len(args) == 2:
+ thread_id = args[1]
+ if thread_id[0] == "$":
+ thread_id = thread_id[1:]
try:
- pm = channel.messages[SlackTS(args[1])]
+ pm = channel.messages[SlackTS(thread_id)]
except:
- pm = channel.hashed_messages[args[1]]
+ pm = channel.hashed_messages[thread_id]
pm.open_thread(switch=config.switch_buffer_on_join)
return w.WEECHAT_RC_OK_EAT
elif args[0] == '/reply':
@@ -3755,6 +3758,9 @@ def line_event_cb(data, signal, hashtable):
elif data == "reply":
w.command(buffer_pointer, "/cursor stop")
w.command(buffer_pointer, "/input insert /reply {}\\x20".format(message_hash))
+ elif data == "thread":
+ w.command(buffer_pointer, "/cursor stop")
+ w.command(buffer_pointer, "/thread {}".format(message_hash))
return w.WEECHAT_RC_OK
@slack_buffer_required
@@ -3898,11 +3904,13 @@ def setup_hooks():
"@chat(python.*.slack.com.*):M": "hsignal:slack_cursor_message",
"@chat(python.*.slack.com.*):D": "hsignal:slack_cursor_delete",
"@chat(python.*.slack.com.*):R": "hsignal:slack_cursor_reply",
+ "@chat(python.*.slack.com.*):T": "hsignal:slack_cursor_thread",
})
w.hook_hsignal("slack_mouse", "line_event_cb", "message")
w.hook_hsignal("slack_cursor_delete", "line_event_cb", "delete")
w.hook_hsignal("slack_cursor_reply", "line_event_cb", "reply")
+ w.hook_hsignal("slack_cursor_thread", "line_event_cb", "thread")
w.hook_hsignal("slack_cursor_message", "line_event_cb", "message")
# Hooks to fix/implement