From 9f0f121c102683c3b52b1bfb35968d8c88414cd8 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Fri, 29 Dec 2023 15:30:51 -0500 Subject: [PATCH] bash mattermost --- utils/send_mmost.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 utils/send_mmost.sh diff --git a/utils/send_mmost.sh b/utils/send_mmost.sh new file mode 100755 index 0000000..24a4b34 --- /dev/null +++ b/utils/send_mmost.sh @@ -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 +