Files
slackecho/slackecho
Atlas 3c5f1f1b12
Some checks failed
Bash Syntax Check / syntax-check (push) Failing after 0s
fix: make slackecho executable
2026-02-11 04:52:37 +00:00

38 lines
820 B
Bash
Executable File

#!/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="slackecho-user"
else
SLACKUSER="$2"
fi
if [ "$3" = "" ]; then
SLACKCH="general"
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