bbs-telnet/mastodon_api.sh

33 lines
1.1 KiB
Bash
Executable File

#/bin/sh
toot(){
message="$(echo "$1" | sed -e 's!/n!\n!g')" # Just my android keyboard too dumb and far
curl -s -X POST -F in_reply_to_id=$reply -F status="$message" -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'
}
notifications_render(){
cat - | jq -r '.[] |
"[\(.type) \(.created_at) \(.account.acct)]",
if .status then
.status.id, .status.pleroma.content."text/plain"
else 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
}
notifications(){
curl -s -H "Authorization: Bearer $instance_token" "https://$instance/api/v1/notifications?limit=40&max_id=$1" | notifications_render
}