-
-
Save alexlopes/82e633974f8a7f8148fb70abc834c4fd to your computer and use it in GitHub Desktop.
Revisions
-
dopiaza created this gist
Sep 5, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/bin/bash # Usage: slackpost <token> <channel> <message> # Enter the name of your slack host here - the thing that appears in your URL: # https://slackhost.slack.com/ slackhost=PUT_YOUR_HOST_HERE token=$1 if [[ $token == "" ]] then echo "No token specified" exit 1 fi shift channel=$1 if [[ $channel == "" ]] then echo "No channel specified" exit 1 fi shift text=$* if [[ $text == "" ]] then echo "No text specified" exit 1 fi escapedText=$(echo $text | sed 's/"/\"/g' | sed "s/'/\'/g" ) json="{\"channel\": \"#$channel\", \"text\": \"$escapedText\"}" curl -s -d "payload=$json" "https://$slackhost.slack.com/services/hooks/incoming-webhook?token=$token"