-
-
Save unascribed/98884acf9eceff8e3fa901fe6e8194ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
token='ACCESS_TOKEN_HERE (needs write.statuses and write.media scopes)' | |
instance='sleeping.town' | |
tmp=`mktemp voidXXXXXX.json` | |
read -ep 'Content warning? ' cw | |
read -ep 'Attachment? ' attachment | |
if [ -n "$attachment" ]; then | |
read -ep 'Attachment alt text? ' alt_text | |
echo "Uploading attachment..." | |
attachment=`curl -s -X POST -H "Authorization: Bearer $token" -F "file=@$attachment;filename=$(date '+%s')" -F "description=$alt_text" https://$instance/api/v1/media` | |
attachment_id=`echo $attachment | jq '.id'` | |
fi | |
echo 'Write your post. ^D to finish, ^C to cancel' | |
jq --slurp -Rr 'rtrimstr("\n")|{status: "\(.) 🌌",spoiler_text:"'"$cw"'",visibility:"unlisted",media_ids:['$attachment_id']}' > $tmp | |
curl -s -X POST -H "Authorization: Bearer $token" -H 'Content-Type: application/json' --data "@$tmp" https://$instance/api/v1/statuses >/dev/null | |
rm $tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment