diff options
author | Aidan Epstein <aidan@jmad.org> | 2020-03-01 12:43:53 -0800 |
---|---|---|
committer | Aidan Epstein <aidan@jmad.org> | 2020-03-01 12:43:53 -0800 |
commit | bdf83ddf0b1842c26c9122603df342c96db87a7b (patch) | |
tree | 77175d30e5df987a239ff6c7130a72d983bd9dc5 /wee_slack.py | |
parent | 5c21c4b441e31a35eb95315cc6880cc357cf3b8d (diff) | |
download | wee-slack-bdf83ddf0b1842c26c9122603df342c96db87a7b.tar.gz |
Change reply argument from -broadcast to -alsochannel, remove
command_broadcast, and change reply to work without the id when in a
thread buffer.
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/wee_slack.py b/wee_slack.py index c72b22c..8b411b6 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -4004,39 +4004,35 @@ command_thread.completion = '%(threads)' @slack_buffer_required @utf8_decode -def command_broadcast(data, current_buffer, args): - """ - /slack broadcast <text> - When in a thread buffer, send a message while broadcasting to the rest of - the channel. - """ - channel = EVENTROUTER.weechat_controller.buffers[current_buffer] - - channel.send_message(args, request_dict_ext={'reply_broadcast': True}) - return w.WEECHAT_RC_OK_EAT - - -@slack_buffer_required -@utf8_decode def command_reply(data, current_buffer, args): """ - /reply [-broadcast] <count/message_id> <text> - Reply in a thread on the message. Specify either the message id - or a count upwards to the message from the last message. + /reply [-alsochannel] <count/message_id> <text> + Reply in a thread on the message. Specify either the message id, a count + upwards to the message from the last message, or, if you are already in a + thread, nothing. """ channel = EVENTROUTER.weechat_controller.buffers[current_buffer] + parts = args.split(None, 1) + if parts[0] == "-alsochannel": + args = parts[1] + broadcast = True + else: + broadcast = False + try: - msg_id, text = args.split(None, 1) - if msg_id == "-broadcast": - msg_id, text = text.split(None, 1) - broadcast = True + if isinstance(channel, SlackThreadChannel): + text = args else: - broadcast = False + msg_id, text = args.split(None, 1) except ValueError: - w.prnt('', 'Usage: /reply [-broadcast] <count/id> <message>') + w.prnt('', 'Usage: /reply [-alsochannel] <count/id> <message>') return w.WEECHAT_RC_OK_EAT - msg = get_msg_from_id(channel, msg_id) + if isinstance(channel, SlackThreadChannel): + msg = channel.parent_message + else: + msg = get_msg_from_id(channel, msg_id) + if msg: parent_id = str(msg.ts) elif msg_id.isdigit() and int(msg_id) >= 1: @@ -4049,7 +4045,7 @@ def command_reply(data, current_buffer, args): channel.send_message(text, request_dict_ext={'thread_ts': parent_id, 'reply_broadcast': broadcast}) return w.WEECHAT_RC_OK_EAT -command_reply.completion = '-broadcast %(threads)||%(threads)' +command_reply.completion = '-alsochannel %(threads)||%(threads)' @slack_buffer_required |