From e98bd8c507d247cea04f14383f44f69fcfc7466a Mon Sep 17 00:00:00 2001 From: Midgard Date: Fri, 20 Oct 2023 17:28:48 +0200 Subject: [PATCH] Add support for replying in thread --- mmcli/mmcli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mmcli/mmcli.py b/mmcli/mmcli.py index e878942..db04de1 100755 --- a/mmcli/mmcli.py +++ b/mmcli/mmcli.py @@ -397,11 +397,11 @@ def send(mm_api: mattermost.MMApi, cmdline_args): print(f"Illegal message, missing channel: {line.strip()}", file=sys.stderr) 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) 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) @@ -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") parser_send.add_argument( "--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( "--attach", nargs="+", help="filename of file to attach")