Skip to content

Instantly share code, notes, and snippets.

@steinn
Last active December 16, 2020 17:51
Show Gist options
  • Save steinn/7920131 to your computer and use it in GitHub Desktop.
Save steinn/7920131 to your computer and use it in GitHub Desktop.
Post random number from random.org to a channel on Slack
#!/bin/bash
RANDOM_URL=http://www.random.org/integers/?num=1\&min=1\&max=100\&col=1\&base=10\&format=plain\&rnd=new
RND_NUMBER=$(curl $RANDOM_URL)
MESSAGE=$RND_NUMBER
USERNAME="random.org"
CHANNEL="#random"
PAYLOAD="payload={\"channel\": \"$CHANNEL\", \"username\": \"$USERNAME\", \"text\": \"$MESSAGE\"}"
TOKEN=<ADD_TOKEN>
SLACK_URL=https://jive.slack.com/services/hooks/incoming-webhook?token=$TOKEN
curl -X POST --data "$PAYLOAD" $SLACK_URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment