Add support for replying in thread

This commit is contained in:
Midgard 2023-10-20 17:28:48 +02:00
parent 5f25113b18
commit e98bd8c507
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -397,11 +397,11 @@ def send(mm_api: mattermost.MMApi, cmdline_args):
print(f"Illegal message, missing channel: {line.strip()}", file=sys.stderr) print(f"Illegal message, missing channel: {line.strip()}", file=sys.stderr)
raise ValueError("Illegal message, missing channel") raise ValueError("Illegal message, missing channel")
sent = mm_api.create_post(channel_id, msg["message"], props={"from_mmcli": "true"}, filepaths=msg.get("attachments", msg.get("attachments"))) sent = mm_api.create_post(channel_id, msg["message"], props={"from_mmcli": "true"}, filepaths=msg.get("attachments", msg.get("attachments")), root_id=msg.get("thread", msg.get("root_id")))
print(sent) print(sent)
else: else:
sent = mm_api.create_post(channel["id"], cmdline_args.message, props={"from_mmcli": "true"}, filepaths=cmdline_args.attach) sent = mm_api.create_post(channel["id"], cmdline_args.message, props={"from_mmcli": "true"}, filepaths=cmdline_args.attach, root_id=cmdline_args.thread)
print(sent) print(sent)
@ -593,6 +593,8 @@ The input format accepted on stdin is one JSON object per line. The possible fie
"messages must be provided on stdin and each must specify channel") "messages must be provided on stdin and each must specify channel")
parser_send.add_argument( parser_send.add_argument(
"--message", help="message; if not provided, messages will be expected on stdin") "--message", help="message; if not provided, messages will be expected on stdin")
parser_send.add_argument(
"--thread", help="message ID of the root message of the thread to post in")
parser_send.add_argument( parser_send.add_argument(
"--attach", nargs="+", help="filename of file to attach") "--attach", nargs="+", help="filename of file to attach")