bash mattermost sender
This commit is contained in:
+12
-8
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user