Skip to content

Instantly share code, notes, and snippets.

@johnSerrano
Last active September 29, 2015 00:05
Show Gist options
  • Save johnSerrano/0f7b1da1bbc9c8bbc607 to your computer and use it in GitHub Desktop.
Save johnSerrano/0f7b1da1bbc9c8bbc607 to your computer and use it in GitHub Desktop.
slackpost
#!/bin/bash
FLAG_n='BOT'
FLAG_c='#general'
FLAG_m=''
while getopts 'n:c:m:h' flag; do
case "${flag}" in
h) echo
echo 'SLACKPOST'
echo 'Author: John Serrano'
echo
echo 'USAGE:'
echo 'slackpost -m <message> [-n <bot name>] [-c <channel>] [-h]'
echo
echo 'Posts to DevGuild Team slack (devguidteam.slack.com)'
echo
exit 0
;;
n) FLAG_n="$OPTARG" ;;
c) FLAG_c="$OPTARG" ;;
m) FLAG_m="$OPTARG" ;;
esac
done
curl -X POST --data-urlencode 'payload={"channel": "'"$FLAG_c"'", "username": "'"$FLAG_n"'", "text": "'"$FLAG_m"'"}' https://hooks.slack.com/services/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
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment