-
Notifications
You must be signed in to change notification settings - Fork 1
/
hipchat
executable file
·57 lines (52 loc) · 1.28 KB
/
hipchat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
COLOR="yellow"
ROOM_ID=31226
FROM="Nobody"
NOTIFY=0
MESSAGE_FORMAT="html"
AUTH_TOKEN=""
while getopts "ha:c:f:m:n:r:" opt
do
case $opt
in
h)
echo "hipchat"
echo ""
echo "usage:"
echo ""
echo " -h - This help screen"
echo " -a AUTH_TOKEN - Authentication token (no default)"
echo " -c COLOR - Color of notification (default: yellow)"
echo " -f FROM - Who to send from (default: Nobody)"
echo " -m MESSAGE_FORMAT - Message format (default: html)"
echo " -n NOTIFY - Whether to notify channel users (default: 0)"
echo " -r ROOM_ID - Room id (default: 31226)"
exit 0
;;
a)
AUTH_TOKEN=$OPTARG
;;
c)
COLOR=$OPTARG
;;
f)
FROM=$OPTARG
;;
m)
MESSAGE_FORMAT=$OPTARG
;;
n)
NOTIFY=$OPTARG
;;
r)
ROOM_ID=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
MESSAGE=`cat`
echo "Sending ${MESSAGE} to room ${ROOM_ID} with auth ${AUTH_TOKEN}"
curl -d "color=${COLOR}&from=${FROM}&message=${MESSAGE}¬ify=${NOTIFY}&room_id=${ROOM_ID}" https://api.hipchat.com/v1/rooms/message?auth_token=${AUTH_TOKEN}&format=${MESSAGE_FORMAT}