From d03be1c65177b7608f345bd66888b8f4345a07c2 Mon Sep 17 00:00:00 2001 From: Stanislav German-Evtushenko Date: Sun, 17 Feb 2019 16:35:26 +0900 Subject: [PATCH] Jsonify stdin for chat send/update commands Fixes #79 --- src/slack | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slack b/src/slack index e309d95..29c8080 100755 --- a/src/slack +++ b/src/slack @@ -292,7 +292,7 @@ function chatdelete() { } function chatsend() { - [ -n "${stdin}" ] && [ -z "${text}" ] && text=\`\`\`${stdin//$'\n'/'\n'}\`\`\` + [ -n "${stdin}" ] && [ -z "${text}" ] && text=$(jq -Rs <<< "$stdin" '"```" + . + "```"' | sed 's/^"//; s/"$//') local msg=$(\ curl -s -X POST https://slack.com/api/chat.postMessage \ @@ -305,7 +305,7 @@ function chatsend() { } function chatupdate() { - [ -n "${stdin}" ] && [ -z "${text}" ] && text=\`\`\`${stdin//$'\n'/'\n'}\`\`\` + [ -n "${stdin}" ] && [ -z "${text}" ] && text=$(jq -Rs <<< "$stdin" '"```" + . + "```"' | sed 's/^"//; s/"$//') local msg=$(\ curl -s -X POST https://slack.com/api/chat.update \