aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorAidan Epstein <aidan@jmad.org>2020-03-20 15:20:25 -0700
committerAidan Epstein <aidan@jmad.org>2020-03-21 08:38:39 -0700
commit90daf70eeba1bd474234e8aec4cef3f2f14c966c (patch)
tree938cc1133e5057b6cfbe38a90603f1055bebd6a4 /wee_slack.py
parentb903c0d1d53eeb1d4626db0858042593b8c5d9cc (diff)
downloadwee-slack-90daf70eeba1bd474234e8aec4cef3f2f14c966c.tar.gz
Add slack subscribe and unsubscribe commands.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py42
1 files changed, 38 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 50cd1b5..01d68dd 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -4132,22 +4132,56 @@ def command_subscribe(data, current_buffer, args):
thread buffer, you can omit the thread id.
"""
channel = EVENTROUTER.weechat_controller.buffers[current_buffer]
+ team = channel.team
- if not args:
+ if args:
+ msg = get_msg_from_id(channel, args)
+ elif isinstance(channel, SlackThreadChannel):
+ msg = channel.parent_message
+ else:
w.prnt('', 'Usage: /slack subscribe <thread>')
return w.WEECHAT_RC_ERROR
+ s = SlackRequest(team, "subscriptions.thread.add",
+ {"channel": channel.identifier, "thread_ts": msg.ts}, channel=channel)
+ EVENTROUTER.receive(s)
+ return w.WEECHAT_RC_OK_EAT
+
+command_subscribe.completion = '%(threads)'
+
+
+@slack_buffer_required
+@utf8_decode
+def command_unsubscribe(data, current_buffer, args):
+ """
+ /slack unsubscribe <thread>
+ Unsubscribe from a thread that has been previously subscribed to, so that
+ you are not alerted to new messages. When in a thread buffer, you can omit
+ the thread id.
+ """
+ channel = EVENTROUTER.weechat_controller.buffers[current_buffer]
+ team = channel.team
+
if args:
msg = get_msg_from_id(channel, args)
-
- if not msg and isinstance(channel, SlackThreadChannel):
+ elif isinstance(channel, SlackThreadChannel):
msg = channel.parent_message
+ else:
+ w.prnt('', 'Usage: /slack subscribe <thread>')
+ return w.WEECHAT_RC_ERROR
- # TODO: Looks like there is no RTM api for this?
+ s = SlackRequest(team, "subscriptions.thread.remove",
+ {"channel": channel.identifier, "thread_ts": msg.ts}, channel=channel)
+ EVENTROUTER.receive(s)
+ return w.WEECHAT_RC_OK_EAT
command_subscribe.completion = '%(threads)'
+def handle_subscriptionsthreadmark(json, eventrouter, team, channel, metadata):
+ dbg(repr(json))
+
+
@slack_buffer_required
@utf8_decode
def command_reply(data, current_buffer, args):