ekardnam 5 tahun lalu
induk
melakukan
b6e8dc8766
1 mengubah file dengan 10 tambahan dan 3 penghapusan
  1. 10 3
      toot.sh

+ 10 - 3
toot.sh

@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # WTFPL!
 
@@ -12,6 +12,7 @@ toot_help(){
     echo " -a=, --alt=    the image description for disabilities"
     echo " -t=, --token=  your API access token"
     echo " -s=, --server= mastodon server"
+    echo " -w,  --warn    the image is marked as sensitive"
     echo ""
     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)"
@@ -41,7 +42,8 @@ toot_upload_image(){
 toot_post(){
     local status="$1"
     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)
     if [ "$error" = "null" ]
     then
@@ -55,6 +57,7 @@ toot_post(){
 
 image_to_toot=""
 image_alt=""
+sensitive="false"
 
 if [ $# -eq 0 ]
 then
@@ -81,6 +84,10 @@ do
         image_alt="${arg#*=}"
         shift
         ;;
+    -w|--warn)
+        sensitive="true"
+        shift
+        ;;
 	*)
 	    ;;
     esac
@@ -97,4 +104,4 @@ then
     image_id=$(toot_upload_image "$image_to_toot" "$image_alt")
 fi
 
-toot_post "$*" "$image_id"
+toot_post "$*" "$image_id" "$sensitive"