Created
July 13, 2016 04:47
-
-
Save copperwall/dfbfbbe845f6b054e48b493e3dc18f01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Get this from the slack account page where you created the webhook. | |
WEBHOOK_URL="" | |
# Set the name of the channel that you set up the webhook to message you in. | |
CHANNEL="#copperbot" | |
# Set the name of the user that you set up the webhook under. | |
USER="copperbot" | |
# If the first argument is "notify", then mention the whole channel. | |
# Also strip out "notify " from the message to send. | |
if [ "$1" = "notify" ]; then | |
PREFIX="<!channel> " | |
TEXT="$PREFIX $(sed -e 's/^notify //g' <<<"$@")" | |
else | |
TEXT="$@" | |
fi | |
curl -s -X POST \ | |
--data "{\"text\": \"$TEXT\", \"channel\": \"$CHANNEL\", \"username\": \"$USER\"}" \ | |
$WEBHOOK_URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment