Compare commits

...

2 Commits

Author SHA1 Message Date
localhost_frssoft b3a414ab7e jq as timeline render function 2023-07-24 02:42:54 +03:00
localhost_frssoft f62ac374a1 separate file 2023-07-24 02:26:39 +03:00
2 changed files with 20 additions and 13 deletions

View File

@ -2,19 +2,6 @@
. ./config
toot(){
curl -s -X POST -F in_reply_to_id=$reply -F status="$1" -F visibility='unlisted' -H "Authorization: Bearer $instance_token" https://$instance/api/v1/statuses
}
timeline_home(){
curl -s -H "Authorization: Bearer $instance_token" "https://$instance/api/v1/timelines/home?limit=40&max_id=$1" |
jq -r '.[] |
if .reblog then
(["bump", .reblog.id, .reblog.account.acct] | join(" ")), .reblog.pleroma.content."text/plain", (.reblog.media_attachments[] | "attach", .url, .description // empty)
else [.id, .account.acct], .pleroma.content."text/plain", (.media_attachments[] | "attach", .url, .description // empty)
end | @text'
}
remote_ip=$SOCAT_PEERADDR
die(){
rm access_granted/"$remote_ip"
@ -26,6 +13,7 @@ mkdir -p -m 700 access_granted
mkdir -p -m 700 access_denied
if [ -f access_denied/"$remote_ip" ]; then exit 0; fi
. ./mastodon_api.sh
generator_session=$(zcat -f $system_dict | shuf -n 2 | tr -d "\n'")
randpadding=$(head -c 8 /dev/urandom | base64)

19
mastodon_api.sh Executable file
View File

@ -0,0 +1,19 @@
#/bin/sh
toot(){
curl -s -X POST -F in_reply_to_id=$reply -F status="$1" -F visibility='unlisted' -H "Authorization: Bearer $instance_token" https://$instance/api/v1/statuses
}
timeline_render(){
cat - | jq -r '.[] |
if .reblog then
"[up^ \(.reblog.id) \(.reblog.account.acct)]", .reblog.pleroma.content."text/plain", (.reblog.media_attachments[] | "+ attach \(.url)", .description // empty)
else "[\(.id) \(.account.acct)]", .pleroma.content."text/plain", (.media_attachments[] | "+ attach \(.url)", .description // empty)
end | @text'
}
timeline_home(){
curl -s -H "Authorization: Bearer $instance_token" "https://$instance/api/v1/timelines/home?limit=40&max_id=$1" | timeline_render
}