Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ $ slack status edit --text lunch --emoji :hamburger:
$
$ # Edit status via short form options:
$ slack status edit --tx lunch -em :hamburger:
$
$ # Clear status at 09:30 today:
$ slack status edit -e "$(date -d '09:30' '+%s')" --tx coffee -em :coffee:
$
$ # Clear status after 5 minutes:
$ slack status edit -e +300 --tx "Back in 5" -em :clock1:
```

## Contributors
Expand Down
9 changes: 7 additions & 2 deletions src/slack
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ while (( "$#" )); do
--comment*|-cm*) comment=${2} ; shift ; shift ;;
--count=*) count=${1/--count=/''} ; shift ;;
--count|-cn*) count=${2} ; shift ; shift ;;
--expire|-e) expire=${2} ; shift ; shift ;;
--emoji=*) emoji=${1/--emoji=/''} ; shift ;;
--emoji*|-em*) emoji=${2} ; shift ; shift ;;
--fields=*) fields=${1/--fields=/''} ; shift ;;
Expand Down Expand Up @@ -407,7 +408,7 @@ function help() {
echo " ${bin} status clear"
echo ' [--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]'
echo
echo " ${bin} status edit [<text> [<emoji>]]"
echo " ${bin} status edit [-e <expire-date>] [<text> [<emoji>]]"
echo ' [--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]'
echo
echo 'Configuration Commands:'
Expand Down Expand Up @@ -647,9 +648,13 @@ function statusclear() {
}

function statusedit() {
if [[ "$expire" =~ ^\+ ]]; then
expire="$(( $(date '+%s') + expire ))"
fi

local msg=$(\
curl -s -X POST https://slack.com/api/users.profile.set \
--data-urlencode "profile={\"status_text\":\"${text}\", \"status_emoji\":\"${emoji}\"}" \
--data-urlencode "profile={\"status_text\":\"${text}\",\"status_expiration\":\"${expire:-0}\",\"status_emoji\":\"${emoji}\"}" \
--data-urlencode "token=${token}")

jqify "${msg}"
Expand Down