Last active
September 29, 2015 00:05
-
-
Save johnSerrano/0f7b1da1bbc9c8bbc607 to your computer and use it in GitHub Desktop.
slackpost
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 | |
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