initial
This commit is contained in:
37
slackecho
Normal file
37
slackecho
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# send message to slack
|
||||
#
|
||||
# $1 message
|
||||
# $2 username - optional
|
||||
# $3 channel - optional
|
||||
# $4 icon - optional
|
||||
if [ "$1" = "" ]; then
|
||||
echo "send message to slack"
|
||||
echo "slackecho <message> [username] [channel] [icon]"
|
||||
exit
|
||||
fi
|
||||
|
||||
SLACKURL="https://hooks.slack.com/services/YOURURL"
|
||||
|
||||
#Setup defaults
|
||||
if [ "$2" = "" ]; then
|
||||
SLACKUSER="git-deploy"
|
||||
else
|
||||
SLACKUSER="$2"
|
||||
fi
|
||||
|
||||
if [ "$3" = "" ]; then
|
||||
SLACKCH="devops"
|
||||
else
|
||||
SLACKCH="$3"
|
||||
fi
|
||||
|
||||
if [ "$4" = "" ]; then
|
||||
SLACKICON=":robot_face:"
|
||||
else
|
||||
SLACKICON="$4"
|
||||
fi
|
||||
|
||||
#build the post form and send it to the slack url
|
||||
curl -X POST --data-urlencode 'payload={"channel": "#'$SLACKCH'", "username": "'$SLACKUSER'", "text": "'"$1"'", "icon_emoji": "'$SLACKICON'"}' $SLACKURL -o /dev/null >/dev/null 2>&1
|
||||
Reference in New Issue
Block a user