bash mattermost sender

This commit is contained in:
2023-12-29 16:43:09 -05:00
parent 333fc41abf
commit 83cc1cd509
3 changed files with 18 additions and 23 deletions
+12 -8
View File
@@ -23,20 +23,24 @@ Cmd="${Cmd} | jq -r '.id'"
channel_id=$(eval ${Cmd})
input=$(cat)
input="$(cat)"
body="{"
body="${body}\\\"channel_id\\\":\\\"${channel_id}\\\""
body="${body}, \\\"message\\\":\\\"${input}\\\""
body="${body}\"channel_id\":\"${channel_id}\""
body="${body}, \"message\":\"${input}\""
body="${body}}"
# replace new line with literal \n
body=$(echo "${body}" |awk '{printf "%s\\n", $0}')
post_url="${url}/api/v4/posts"
Cmd="curl -s"
Cmd="${Cmd} -X POST"
Cmd="${Cmd} -H \"Content-Type: Application/JSON\""
Cmd="${Cmd} -H \"Authorization: Bearer ${bearer}\""
Cmd="${Cmd} --data \"${body}\""
Cmd="${Cmd} --request POST"
Cmd="${Cmd} --header \"Content-Type: Application/JSON\""
Cmd="${Cmd} --header \"Authorization: Bearer ${bearer}\""
Cmd="${Cmd} --data @-"
Cmd="${Cmd} ${post_url}"
eval ${Cmd} > /dev/null
(echo "${body}" | eval ${Cmd}) > /dev/null