Skip to content

Instantly share code, notes, and snippets.

@copperwall
Created July 13, 2016 04:47
Show Gist options
  • Save copperwall/dfbfbbe845f6b054e48b493e3dc18f01 to your computer and use it in GitHub Desktop.
Save copperwall/dfbfbbe845f6b054e48b493e3dc18f01 to your computer and use it in GitHub Desktop.
#!/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