You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
689 B

#!/bin/sh
# check usage
if [ $# -ne 3 ]; then
echo "mattermost-post: ERROR: invalid number of arguments" 1>&2
echo "mattermost-post: USAGE: $0 <access-token> <channel-id> <message>" 1>&2
exit 1
fi
# take over arguments
token="$1"
channel="$2"
message="$3"
# determine REST endpoint URL
endpoint=`grep SiteURL @l_prefix@/etc/mattermost/mattermost.json | \
sed -e 's;,*"SiteURL"[^"]*"\([^"]*\)".*;;'`
endpoint="$endpoint/api/v4/posts"
# post message
@l_prefix@/bin/curl \
-i \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $token" \
-d "{ \"channel_id\": \"$channel\", \"message\": \"$message\" }" \
$endpoint