Skip to content

Instantly share code, notes, and snippets.

@radmen
Last active July 18, 2018 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radmen/baac8ff449b1a152ff1cdf6855b74b73 to your computer and use it in GitHub Desktop.
Save radmen/baac8ff449b1a152ff1cdf6855b74b73 to your computer and use it in GitHub Desktop.
Simple AFK script

This simple Bash function will post a short message to #afk Slack channel.

After posting the message it will wait for user interaction on which it will post a message that the user returned.

To run it:

  1. generate legacy token for selected workspace
  2. add it to declaration of TOKEN variable
  3. import somewhere (eg .bash_aliases) function from afk.sh file
afk ()
{
declare -r MESSAGE_RAW="${@:-"30 min"}"
declare -r MESSAGE="$(echo "$MESSAGE_RAW" | tr '[:space:]' '+')"
declare -r TOKEN=""
curl "https://slack.com/api/chat.postMessage?token=$TOKEN&channel=%23afk&text=$MESSAGE&as_user=true"
echo ""
read -p "Press any key to exit" -n 1
curl "https://slack.com/api/chat.postMessage?token=$TOKEN&channel=%23afk&text=Back&as_user=true"
echo ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment