-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_status.sh
More file actions
executable file
·33 lines (23 loc) · 834 Bytes
/
Copy pathget_status.sh
File metadata and controls
executable file
·33 lines (23 loc) · 834 Bytes
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
#!/usr/bin/env bash
if [[ -z "${SLACK_TOKEN}" ]]; then
echo "Missing SLACK_TOKEN environment variable"
exit 1
fi
header="Authorization: Bearer ${SLACK_TOKEN}"
header2="Content-Type: application/json;charset=utf-8"
api_base="https://slack.com/api"
# Get presence
response_presence=$(curl -s\
--url "${api_base}/users.getPresence"\
--header "${header}"\
--header "${header2}")
# Get custom status
response=$(curl -s\
--url "${api_base}/users.profile.get"\
--header "${header}"\
--header "${header2}")
# Extract status text from the response using 'jq'
presence_text=$(echo "$response_presence" | jq -r '.presence')
status_text=$(echo "$response" | jq -r '.profile.status_text')
timenow=$(date +"%Y-%m-%d %H:%M:%S")
echo "[$timenow] Presence: $presence_text\tCurrent Slack status: $status_text"