bash mattermost
This commit is contained in:
parent
96cfa45f98
commit
9f0f121c10
44
utils/send_mmost.sh
Executable file
44
utils/send_mmost.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
url=https://cloud11.cryptovaltrading.com
|
||||
team=CVTT
|
||||
channel_name=${1}
|
||||
bearer=5ysaaxjeijrwjbmhuzcuos9ano
|
||||
|
||||
if [ "" == "${channel_name}" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
get_channel_url="${url}/api/v4/teams/name/${team}/channels/name/${channel_name}"
|
||||
|
||||
Cmd="curl -s"
|
||||
Cmd="${Cmd} -X GET"
|
||||
Cmd="${Cmd} -H \"Content-Type: Application/JSON\""
|
||||
Cmd="${Cmd} -H \"Authorization: Bearer ${bearer}\""
|
||||
Cmd="${Cmd} ${get_channel_url}"
|
||||
Cmd="${Cmd} | jq -r '.id'"
|
||||
|
||||
channel_id=$(eval ${Cmd})
|
||||
|
||||
|
||||
# echo "$channel_id"
|
||||
input=$(cat)
|
||||
body="{"
|
||||
body="${body}\\\"channel_id\\\":\\\"${channel_id}\\\""
|
||||
body="${body}, \\\"message\\\":\\\"${input}\\\""
|
||||
body="${body}}"
|
||||
|
||||
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} ${post_url}"
|
||||
|
||||
# echo ${Cmd}
|
||||
# echo
|
||||
eval ${Cmd} > /dev/null
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user