Skip to content

Instantly share code, notes, and snippets.

@daragao
Last active January 29, 2020 13:49
Show Gist options
  • Save daragao/1cd146c72c6d18d6aecbd2cb4ad1a6cb to your computer and use it in GitHub Desktop.
Save daragao/1cd146c72c6d18d6aecbd2cb4ad1a6cb to your computer and use it in GitHub Desktop.
Slack Spammer
#!/bin/bash
# need curl and jq installed
# go to https://api.slack.com/apps and create an app
# add OAuth permissions:
# calls:write
# channels:join
# channels:manage
# channels:read
# chat:write
# users:read
# OAuth token
OAUTH_TOKEN=xoxb-aaaaaaaaaa-aaaaaaaaaaaa-aaaaaaaaaaaaaaaaaaaaaaaa
# channel name
CHANNEL=channel-name
# message to send
TEXT=test_message
#user id (obtained from https://slack.com/api/users.list?)
USER_ID=U93NGFZK5
# message channel
# JOIN_CHANNEL=$(curl -s -X POST -H "Authorization: Bearer $OAUTH_TOKEN" -H 'Content-type: application/json' --data '{"name": "'$CHANNEL'"}' https://slack.com/api/channels.join)
# CHANNEL_ID=$(echo $JOIN_CHANNEL | jq -r .channel.id)
# curl -s -X POST -H "Authorization: Bearer $OAUTH_TOKEN" -H 'Content-type: application/json' --data '{"channel": "'$CHANNEL'", "text": "'$TEXT'" }' https://slack.com/api/chat.postMessage | jq .
# curl -s -X POST -H "Authorization: Bearer $OAUTH_TOKEN" -H 'Content-type: application/json' --data '{"channel": "'$CHANNEL_ID'"}' https://slack.com/api/channels.leave | jq .
# message person
for i in {1..10000}
do
RANDOM_FACT=$(curl -s https://uselessfacts.jsph.pl/random.json?language=de | jq -r .text)
TEXT="test $i"
DATA=$(echo '{"channel": "'$USER_ID'", "text": "'Fact \#$i - $RANDOM_FACT'" }')
MESSAGE=$(curl -s -X POST -H "Authorization: Bearer $OAUTH_TOKEN" -H 'Content-type: application/json' --data "$DATA" https://slack.com/api/chat.postMessage)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment