Last active
January 3, 2016 21:49
-
-
Save chrislopresto/8524506 to your computer and use it in GitHub Desktop.
A bash executable with command line options to post into hall rooms
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 | |
# A convenient way to post to Hall rooms from the command line... as Lionel Richie | |
# | |
# Usage | |
# ./hall_message | |
# ./hall_message -m "Hello..." | |
# ./hall_message -p https://pbs.twimg.com/profile_images/421128111086764032/zv1APHT5.jpeg -t justin -m "I'll be your platinum, I'll be your silver, I'll be your gold" | |
# Hall integration guide..... https://hall.com/docs/integrations/generic/?uuid=523d0fc3e1681a6757f70ea0 | |
# bash indirect references... http://tldp.org/LDP/abs/html/ivr.html | |
# Add a default room where this script can post. | |
# If you had a room with the token 0123456789abcdef, you | |
# would add it as follows | |
# | |
# ROOM_API_TOKEN_DEFAULT='0123456789abcdef' | |
# | |
# and post messages to it as follows: | |
# | |
# ./hall_message | |
ROOM_API_TOKEN_DEFAULT='YOUR_TOKEN_GOES_HERE' | |
ROOM=$ROOM_API_TOKEN_DEFAULT | |
# Add your room name/token combinations here using the following format: | |
# ROOM_API_TOKEN_ROOMNAME='ROOMKEY' | |
# | |
# If you had a room named Commodores with the token 0123456789abcdef, you | |
# would add it as follows: | |
# | |
# ROOM_API_TOKEN_COMMODORES='0123456789abcdef' | |
# | |
# and post messages to it as follows: | |
# | |
# ./hall_message -n COMMODORES -m "Easy like Sunday morning" | |
ROOM_API_TOKEN_YOURROOMNAMEGOESHERE='YOUR_ROOM_TOKEN_GOES_HERE' | |
TITLE='Lionel Richie' | |
MESSAGE="Hello... is it me you're looking for?" | |
PICTURE='https://pbs.twimg.com/profile_images/378800000712297666/1b78a729761feed16a2c571a8c390743.jpeg' | |
while getopts "m:r:t:p:n:" OPTION; do | |
case $OPTION in | |
m) MESSAGE=$OPTARG ;; | |
n) | |
ROOM_KEY="ROOM_API_TOKEN_$OPTARG" | |
eval ROOM=\$$ROOM_KEY | |
;; | |
t) TITLE=$OPTARG ;; | |
p) PICTURE=$OPTARG ;; | |
r) ROOM=$OPTARG ;; | |
esac | |
done | |
ENDPOINT="https://hall.com/api/1/services/generic/$ROOM" | |
curl \ | |
-X POST \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"title\":\"$TITLE\",\"message\":\"$MESSAGE\",\"picture\":\"$PICTURE\"}" \ | |
"$ENDPOINT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment