- 
      
- 
        Save aroyrev/3f1e4c4ea05156d33932c9455d39b829 to your computer and use it in GitHub Desktop. 
Revisions
- 
        mattak revised this gist Feb 20, 2015 . 1 changed file with 12 additions and 14 deletions.There are no files selected for viewingThis 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 @@ -1,23 +1,21 @@ #!bash -e TOKEN= # slack token is generate from: https://api.slack.com/web CHANNEL= # name of channels or group MESSAGE= # message NICK= # bot name IS_PRIVATE= # 1 or 0 if [ $IS_PRIVATE -eq 1 ]; then API_TYPE=groups else API_TYPE=channels fi # channel info CHANNELS_RESPONSE=$(curl "https://slack.com/api/$API_TYPE.list?token=$TOKEN") CHANNEL_ID=$(echo $CHANNELS_RESPONSE | jq ".${API_TYPE}[]" | jq "if .name == \"$CHANNEL\" then .id else null end" -M -c -r | grep -v null) # post message 
- 
        mattak created this gist Feb 20, 2015 .There are no files selected for viewingThis 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,29 @@ #!bash -e TOKEN= CHANNEL= MESSAGE= NICK= # base info AUTH_RESPONSE=$(curl https://slack.com/api/auth.test) TEAM=$(echo $AUTH_RESPONSE | jq '.team') TEAM_ID=$(echo $AUTH_RESPONSE | jq '.team_id') USER_ID=$(echo $AUTH_RESPONSE | jq '.user_id') URL=$(echo $AUTH_RESPONSE | jq '.url') USER=$(echo $AUTH_RESPONSE | jq '.user') # channel info CHANNELS_RESPONSE=$(curl "https://slack.com/api/groups.list?token=$TOKEN") CHANNEL_ID=$(echo $CHANNELS_RESPONSE | jq '.groups[]' | jq "if .name == \"$CHANNEL\" then .id else null end" -M -c -r | grep -v null) # post message curl -X POST \ -F token=$TOKEN \ -F channel=$CHANNEL_ID \ -F "text=$MESSAGE" \ -F username=$NICK \ https://slack.com/api/chat.postMessage