Created
January 17, 2015 04:54
-
-
Save siteshen/be345fb162fb661e7b7d to your computer and use it in GitHub Desktop.
Slack client in bash
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/bash | |
# https://your-team.slack.com/services/new/incoming-webhook | |
WEBHOOK_URL='' | |
CHANNEL='#dev' | |
USERNAME='sentry' | |
iCON_URL='https://slack.global.ssl.fastly.net/17635/img/services/sentry_128.png' | |
function post_message() { | |
payload="{'username': '$USERNAME', 'text': '$AT_USER $1', 'channel': '$CHANNEL', 'icon_url': '$ICON_URL'}" | |
json=$(echo $payload | sed -e "s/'/\"/g") | |
curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' -X POST -d "$json" "$WEBHOOK_URL" | |
} | |
if [[ $# -eq 0 ]]; then | |
echo "usage: $0 message" | |
exit 1 | |
else | |
post_message $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment