forked from encrypt/toot
added cw
This commit is contained in:
parent
42193183c9
commit
b6e8dc8766
1 changed files with 10 additions and 3 deletions
13
toot.sh
13
toot.sh
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
# WTFPL!
|
# WTFPL!
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ toot_help(){
|
||||||
echo " -a=, --alt= the image description for disabilities"
|
echo " -a=, --alt= the image description for disabilities"
|
||||||
echo " -t=, --token= your API access token"
|
echo " -t=, --token= your API access token"
|
||||||
echo " -s=, --server= mastodon server"
|
echo " -s=, --server= mastodon server"
|
||||||
|
echo " -w, --warn the image is marked as sensitive"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Mastodon server can be set in ~/.tootrc otherwise it will be defaulted to $MASTODON_SERVER"
|
echo "Mastodon server can be set in ~/.tootrc otherwise it will be defaulted to $MASTODON_SERVER"
|
||||||
echo "The token can be passed as, cli argument, var in ~/.tootrc, env var (in this priority order)"
|
echo "The token can be passed as, cli argument, var in ~/.tootrc, env var (in this priority order)"
|
||||||
|
@ -41,7 +42,8 @@ toot_upload_image(){
|
||||||
toot_post(){
|
toot_post(){
|
||||||
local status="$1"
|
local status="$1"
|
||||||
local image="$2"
|
local image="$2"
|
||||||
local data="status=$status&media_ids[]=$image"
|
local sensitive="$3"
|
||||||
|
local data="status=$status&media_ids[]=$image&sensitive=$sensitive"
|
||||||
local error=$(curl --header "Authorization: Bearer $MASTODON_TOKEN" -sS -X POST https://$MASTODON_SERVER/api/v1/statuses -d "$data" | jq -r .error)
|
local error=$(curl --header "Authorization: Bearer $MASTODON_TOKEN" -sS -X POST https://$MASTODON_SERVER/api/v1/statuses -d "$data" | jq -r .error)
|
||||||
if [ "$error" = "null" ]
|
if [ "$error" = "null" ]
|
||||||
then
|
then
|
||||||
|
@ -55,6 +57,7 @@ toot_post(){
|
||||||
|
|
||||||
image_to_toot=""
|
image_to_toot=""
|
||||||
image_alt=""
|
image_alt=""
|
||||||
|
sensitive="false"
|
||||||
|
|
||||||
if [ $# -eq 0 ]
|
if [ $# -eq 0 ]
|
||||||
then
|
then
|
||||||
|
@ -81,6 +84,10 @@ do
|
||||||
image_alt="${arg#*=}"
|
image_alt="${arg#*=}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-w|--warn)
|
||||||
|
sensitive="true"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -97,4 +104,4 @@ then
|
||||||
image_id=$(toot_upload_image "$image_to_toot" "$image_alt")
|
image_id=$(toot_upload_image "$image_to_toot" "$image_alt")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
toot_post "$*" "$image_id"
|
toot_post "$*" "$image_id" "$sensitive"
|
||||||
|
|
Loading…
Reference in a new issue