davidvasandani
3/24/2018 - 3:32 PM

Custom Slack Away Messages

Custom Slack Away Messages

export SLACK_CLI_TOKEN='####'

alias dog_slack="/usr/bin/curl -s -X POST \
  https://slack.com/api/users.profile.set \
  --data-urlencode 'profile={\"status_text\":\"walking the dogs\", \"status_emoji\":\":dog2:\"}' \
  --data-urlencode 'token=$SLACK_CLI_TOKEN' | jq '.profile.status_text'"

alias lunch_slack="/usr/bin/curl -s -X POST \
  https://slack.com/api/users.profile.set \
  --data-urlencode 'profile={\"status_text\":\"getting lunch\", \"status_emoji\":\":taco:\"}' \
  --data-urlencode 'token=$SLACK_CLI_TOKEN' | jq '.profile.status_text'"

alias empty_slack="/usr/bin/curl -s -X POST \
  https://slack.com/api/users.profile.set \
  --data-urlencode 'profile={\"status_text\":\"\", \"status_emoji\":\"\"}' \
  --data-urlencode 'token=$SLACK_CLI_TOKEN' | jq '.profile.status_text'"

alias away_slack="/usr/bin/curl -s -X POST \
  https://slack.com/api/users.setPresence \
  --data-urlencode 'presence=away' \
  --data-urlencode 'token=$SLACK_CLI_TOKEN' | jq '.ok'"

alias back_slack="/usr/bin/curl -s -X POST \
  https://slack.com/api/users.setPresence \
  --data-urlencode 'presence=auto' \
  --data-urlencode 'token=$SLACK_CLI_TOKEN' | jq '.ok'"

alias dog='dog_slack; away_slack'

alias lunch='lunch_slack; away_slack'

alias back='empty_slack; back_slack'

alias away='empty_slack; away_slack'