blackhand-mastodon-bot/send-quote

13 lines
447 B
Text
Raw Normal View History

2023-08-09 15:48:36 +00:00
#/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"