forked from bida/MastodonMegafono
fix in toot.sh
This commit is contained in:
parent
5621cfe1fa
commit
e491bf729f
1 changed files with 18 additions and 5 deletions
23
toot.sh
23
toot.sh
|
@ -39,7 +39,7 @@ toot_upload_image(){
|
|||
exit 1
|
||||
}
|
||||
|
||||
toot_post(){
|
||||
toot_post_with_image(){
|
||||
local status="$1"
|
||||
local image="$2"
|
||||
local sensitive="$3"
|
||||
|
@ -52,7 +52,19 @@ toot_post(){
|
|||
echo $error
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
toot_post(){
|
||||
local status="$1"
|
||||
local data="status=$status"
|
||||
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
|
||||
echo "[$(date)][INFO] Tooted: $status"
|
||||
else
|
||||
echo $error
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
image_to_toot=""
|
||||
|
@ -99,9 +111,10 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n $image_to_toot ] && [ -f $image_to_toot ]
|
||||
if [ "$image_to_toot" != "" ] && [ -f $image_to_toot ]
|
||||
then
|
||||
image_id=$(toot_upload_image "$image_to_toot" "$image_alt")
|
||||
fi
|
||||
|
||||
toot_post "$*" "$image_id" "$sensitive"
|
||||
toot_post_with_image "$*" "$image_id" "$sensitive"
|
||||
else
|
||||
toot_post "$*" "$image_id" "$sensitive"
|
||||
fi
|
Loading…
Reference in a new issue