Change reply argument from -broadcast to -alsochannel, remove
command_broadcast, and change reply to work without the id when in a
thread buffer.
@@ -4002,41 +4002,37 @@ def command_thread(data, current_buffer, args):
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]
- try:
- msg_id, text = args.split(None, 1)
- if msg_id == "-broadcast":
- msg_id, text = text.split(None, 1)
+ parts = args.split(None, 1)
+ if parts[0] == "-alsochannel":
+ args = parts[1]
broadcast = True
else:
broadcast = False
+
+ try:
+ if isinstance(channel, SlackThreadChannel):
+ text = args
+ else:
+ 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
+ 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
