blackhand-mastodon-bot/send-quote
Ramses Revengeday 88a39f750a Initial commit
Initial commit
2023-08-09 17:48:36 +02:00

12 lines
447 B
Text

#/bin/bash
PATH=YOUR-PATH
# Calculate number of entries in json datafile
MAXNUMBER=$(/YOUR-PATH-TO-JQ/jq '.[].post' /posts.json | wc -l)
# Fetch random entry from json datafile
QUOTE=$(/YOUR-PATH-TO-JQ/jq --argjson randomnumber $((RANDOM % $MAXNUMBER)) '.[$randomnumber].post' /YOUR-PATH/posts.json)
QUOTE="status=${QUOTE}"
# Go!
/usr/bin/curl -g https://YOUR-INSTANCE.TLD/api/v1/statuses -H 'Authorization: Bearer YOUR-ACCESS-KEY' -F "$QUOTE"