2022-04-11 19:34:04 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
instance=$(jj -i config.json instance)
|
2022-04-13 21:07:02 +00:00
|
|
|
alias default_auth_browser=links
|
2022-04-11 19:34:04 +00:00
|
|
|
instance_point="https://$instance/api/v1"
|
2022-04-13 16:30:59 +00:00
|
|
|
instance_point_pleroma="https://$instance/api/pleroma"
|
2022-04-11 19:34:04 +00:00
|
|
|
instance_hist='instance.hist'
|
2022-04-15 12:03:35 +00:00
|
|
|
enabled_nsfw=$(jj -i config.json enabled_nsfw)
|
2022-04-19 07:49:53 +00:00
|
|
|
hide_reblogs=$(jj -i config.json hide_reblogs)
|
2022-04-11 19:34:04 +00:00
|
|
|
max_statuses=$(jj -i config.json max_statuses)
|
|
|
|
default_visibility=$(jj -i config.json default_visibility)
|
|
|
|
default_content_type=$(jj -i config.json default_content_type)
|
2022-04-12 18:06:23 +00:00
|
|
|
format_time=$(jj -i config.json format_time)
|
|
|
|
boost_symbol=$(jj -i config.json boost_symbol)
|
2022-04-15 17:05:15 +00:00
|
|
|
statuses_separator=$(jj -i config.json statuses_separator)
|
2022-04-14 23:02:55 +00:00
|
|
|
reversed_statuses=$(jj -i config.json reversed_statuses)
|
2022-04-15 07:53:57 +00:00
|
|
|
quoting_reply=$(jj -i config.json quoting_reply)
|
2022-04-17 00:06:20 +00:00
|
|
|
copy_mentions=$(jj -i config.json copy_mentions)
|
2022-04-18 20:54:01 +00:00
|
|
|
per_status_mode=$(jj -i config.json per_status_mode)
|
2022-04-11 19:34:04 +00:00
|
|
|
|
2022-04-13 12:52:25 +00:00
|
|
|
#[AUTH SECTION]
|
2022-04-11 19:34:04 +00:00
|
|
|
mkdir -m 711 -p .app_sessions
|
|
|
|
touch .auth.json
|
|
|
|
chmod 600 .auth.json
|
2022-04-18 06:43:25 +00:00
|
|
|
auth="$(jj -i .auth.json "$(echo "$instance" | sed 's/\./\\\./g')")"
|
2022-04-11 19:34:04 +00:00
|
|
|
echo "Instance: $instance"
|
|
|
|
if [ -n "$auth" ]; then
|
|
|
|
default_curl_opt()
|
|
|
|
{
|
2022-04-13 23:51:46 +00:00
|
|
|
curl -s --compressed -H "Authorization: Bearer $auth" "$@"
|
|
|
|
}
|
|
|
|
post_request()
|
|
|
|
{
|
|
|
|
curl -s --compressed -X POST -H "Authorization: Bearer $auth" "$@"
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
echo '+Authorized account+'
|
|
|
|
else
|
|
|
|
default_curl_opt()
|
|
|
|
{
|
2022-04-18 06:43:25 +00:00
|
|
|
curl -s --compressed "$1"
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
echo 'Please make auth and restart'
|
|
|
|
fi
|
|
|
|
|
|
|
|
auth_api_create_client()
|
|
|
|
{
|
2022-04-11 22:27:27 +00:00
|
|
|
if [ ! -e ".app_sessions/$instance" ]; then
|
2022-04-18 06:43:25 +00:00
|
|
|
curl -s --compressed --url "$instance_point/apps" \
|
2022-04-11 22:27:27 +00:00
|
|
|
--data-urlencode 'client_name=pleroma-cli' \
|
|
|
|
--data-urlencode 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' \
|
|
|
|
--data-urlencode 'scopes=read write follow' \
|
|
|
|
--data-urlencode 'website=https://gitea.phreedom.club/localhost_frssoft/pleroma-cli' \
|
2022-04-18 06:43:25 +00:00
|
|
|
--output ".app_sessions/$instance" \
|
|
|
|
--create-file-mode 0600
|
2022-04-11 22:27:27 +00:00
|
|
|
fi
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auth_api_get_code()
|
|
|
|
{
|
|
|
|
auth_api_create_client
|
2022-04-18 06:43:25 +00:00
|
|
|
client_id=$(jj -i ".app_sessions/$instance" client_id)
|
2022-04-13 21:07:02 +00:00
|
|
|
default_auth_browser "https://$instance/oauth/authorize?client_id=$client_id&response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=read+write+follow"
|
2022-04-11 19:34:04 +00:00
|
|
|
echo 'Input token-code:'
|
|
|
|
read pass
|
|
|
|
}
|
|
|
|
|
|
|
|
auth_api_get_token()
|
|
|
|
{
|
|
|
|
auth_api_get_code
|
|
|
|
clear
|
2022-04-18 06:43:25 +00:00
|
|
|
client_id=$(jj -i ".app_sessions/$instance" client_id)
|
|
|
|
client_secret=$(jj -i ".app_sessions/$instance" client_secret)
|
|
|
|
token=$(curl -s --compressed --url "https://$instance/oauth/token" \
|
2022-04-11 19:34:04 +00:00
|
|
|
--data-urlencode 'grant_type=authorization_code' \
|
|
|
|
--data-urlencode "client_id=$client_id" \
|
|
|
|
--data-urlencode "client_secret=$client_secret" \
|
|
|
|
--data-urlencode "redirect_uri=urn:ietf:wg:oauth:2.0:oob" \
|
|
|
|
--data-urlencode 'scope=read write follow' \
|
|
|
|
--data-urlencode "code=$pass" | jj access_token)
|
2022-04-18 06:43:25 +00:00
|
|
|
jj -p -i .auth.json -v "$token" "$(echo "$instance" | sed 's/\./\\\./g')" -o .auth.json
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
2022-04-13 12:52:25 +00:00
|
|
|
#[AUTH SECTION END]
|
|
|
|
|
|
|
|
#[MIGRATION SECTION]
|
2022-04-13 17:50:48 +00:00
|
|
|
backup_restore_menu()
|
|
|
|
{
|
|
|
|
clear
|
|
|
|
echo "Backup/Restore menu
|
|
|
|
Backups will be placed to folder backups_$instance
|
|
|
|
Hint:
|
|
|
|
For restore create folder 'restore' and copy 'friends.csv, blocks.csv, mutes.csv' in to folder
|
|
|
|
Note: check selected instance before backup/restore"
|
|
|
|
sub_menu_lvl=1
|
|
|
|
entry1='Backup followings'
|
|
|
|
entry2='Backup blocks'
|
|
|
|
entry3='Backup mutes'
|
|
|
|
entry4='Backup all'
|
|
|
|
entry5='Restore followings'
|
|
|
|
entry6='Restore blocks'
|
|
|
|
entry7='Restore mutes'
|
|
|
|
entry8='Restore all'
|
|
|
|
while [ $sub_menu_lvl -eq 1 ]; do
|
|
|
|
choice=$(echo "Main menu\n$entry1\n$entry2\n$entry3\n$entry4\n$entry5\n$entry6\n$entry7\n$entry8" | fzy)
|
|
|
|
case $choice in
|
|
|
|
"Main menu") sub_menu_lvl=0 ;;
|
|
|
|
"$entry1") follow_api_export ;;
|
|
|
|
"$entry2") blocks_api_export ;;
|
|
|
|
"$entry3") mutes_api_export ;;
|
|
|
|
"$entry4")
|
|
|
|
echo 'Initialized... Please wait...'
|
|
|
|
follow_api_export
|
|
|
|
sleep 3
|
|
|
|
blocks_api_export
|
|
|
|
sleep 3
|
|
|
|
mutes_api_export
|
|
|
|
;;
|
|
|
|
"$entry5") follow_api_import ;;
|
|
|
|
"$entry6") blocks_api_import ;;
|
|
|
|
"$entry7") mutes_api_import ;;
|
|
|
|
"$entry8")
|
|
|
|
echo 'Initialized... Please wait...'
|
|
|
|
follow_api_import
|
|
|
|
sleep 5
|
|
|
|
blocks_api_import
|
|
|
|
sleep 5
|
|
|
|
mutes_api_import
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-13 12:52:25 +00:00
|
|
|
backup_api_create()
|
|
|
|
{
|
2022-04-13 20:34:03 +00:00
|
|
|
post_request "$instance_point/pleroma/backups"
|
2022-04-13 12:52:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
backup_api_list()
|
|
|
|
{
|
2022-04-13 20:34:03 +00:00
|
|
|
default_curl_opt "$instance_point/pleroma/backups"
|
2022-04-13 12:52:25 +00:00
|
|
|
}
|
|
|
|
|
2022-04-13 22:29:48 +00:00
|
|
|
legacy_addr_preprocess()
|
|
|
|
{
|
|
|
|
sed -E "/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$/! s/$/@$instance/"
|
|
|
|
}
|
|
|
|
|
2022-04-13 16:30:59 +00:00
|
|
|
follow_api_export()
|
|
|
|
{
|
|
|
|
count=40
|
2022-04-18 06:43:25 +00:00
|
|
|
mkdir -m 711 -p backups_"$instance"
|
2022-04-13 16:30:59 +00:00
|
|
|
account_info=$(account_api_me)
|
2022-04-18 06:43:25 +00:00
|
|
|
acc_id=$(echo "$account_info" | jj id)
|
|
|
|
acc_following_count=$(echo "$account_info" | jj following_count)
|
2022-04-13 16:30:59 +00:00
|
|
|
while [ $count -gt 0 ]; do
|
2022-04-18 06:43:25 +00:00
|
|
|
followings=$(followings_api_get "$acc_id")
|
|
|
|
count=$(echo "$followings" | jj \#)
|
|
|
|
if [ "$count" -eq 0 ]; then
|
2022-04-14 10:48:58 +00:00
|
|
|
echo "$acc_following_count followings exported"
|
2022-04-18 06:43:25 +00:00
|
|
|
elif [ "$count" -lt 40 ]; then
|
|
|
|
countindex=$(expr "$count" - 1)
|
|
|
|
echo "$followings" | jj -l \#.acct | delq | legacy_addr_preprocess >> "backups_$instance"/friends.csv
|
|
|
|
offset=$(echo "$followings" | jj "$countindex".id)
|
2022-04-13 17:14:22 +00:00
|
|
|
echo "+$count follows"
|
|
|
|
count=0
|
|
|
|
echo "$acc_following_count followings exported"
|
|
|
|
elif [ $count -gt 0 ]; then
|
2022-04-13 16:30:59 +00:00
|
|
|
countindex=$(expr $count - 1)
|
2022-04-18 06:43:25 +00:00
|
|
|
echo "$followings" | jj -l \#.acct | delq | legacy_addr_preprocess >> "backups_$instance"/friends.csv
|
|
|
|
offset=$(echo "$followings" | jj "$countindex".id)
|
2022-04-13 16:30:59 +00:00
|
|
|
echo "+$count follows"
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-13 17:14:22 +00:00
|
|
|
blocks_api_export()
|
2022-04-13 12:52:25 +00:00
|
|
|
{
|
2022-04-13 17:14:22 +00:00
|
|
|
count=40
|
2022-04-18 06:43:25 +00:00
|
|
|
mkdir -m 711 -p "backups_$instance"
|
2022-04-13 17:14:22 +00:00
|
|
|
while [ $count -gt 0 ]; do
|
|
|
|
blocks=$(blocks_api_get)
|
2022-04-18 06:43:25 +00:00
|
|
|
count=$(echo "$blocks" | jj \#)
|
|
|
|
if [ "$count" -eq 0 ]; then
|
2022-04-14 10:48:58 +00:00
|
|
|
echo "Blocks exported"
|
2022-04-18 06:43:25 +00:00
|
|
|
elif [ "$count" -lt 40 ]; then
|
|
|
|
countindex=$(expr "$count" - 1)
|
|
|
|
echo "$blocks" | jj -l \#.acct | delq | legacy_addr_preprocess >> "backups_$instance"/blocks.csv
|
|
|
|
offset=$(echo "$blocks" | jj "$countindex".id)
|
2022-04-13 17:14:22 +00:00
|
|
|
echo "+$count blocks"
|
|
|
|
count=0
|
|
|
|
echo "Blocks exported"
|
|
|
|
elif [ $count -gt 0 ]; then
|
2022-04-18 06:43:25 +00:00
|
|
|
echo "$blocks" | jj -l \#.acct | delq | legacy_addr_preprocess >> "backups_$instance"/blocks.csv
|
|
|
|
offset=$(echo "$blocks" | jj "$countindex".id)
|
2022-04-13 17:14:22 +00:00
|
|
|
echo "+$count blocks"
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
2022-04-13 12:52:25 +00:00
|
|
|
}
|
|
|
|
|
2022-04-13 17:14:22 +00:00
|
|
|
mutes_api_export()
|
2022-04-13 12:52:25 +00:00
|
|
|
{
|
2022-04-13 17:14:22 +00:00
|
|
|
count=40
|
2022-04-18 06:43:25 +00:00
|
|
|
mkdir -m 711 -p "backups_$instance"
|
2022-04-13 17:14:22 +00:00
|
|
|
while [ $count -gt 0 ]; do
|
|
|
|
mutes=$(mutes_api_get)
|
2022-04-18 06:43:25 +00:00
|
|
|
count=$(echo "$mutes" | jj \#)
|
|
|
|
if [ "$count" -eq 0 ]; then
|
2022-04-14 10:48:58 +00:00
|
|
|
echo "Mutes exported"
|
2022-04-18 06:43:25 +00:00
|
|
|
elif [ "$count" -lt 40 ]; then
|
|
|
|
countindex=$(expr "$count" - 1)
|
|
|
|
echo "$mutes" | jj -l \#.acct | delq | legacy_addr_preprocess >> "backups_$instance"/mutes.csv
|
|
|
|
offset=$(echo "$mutes" | jj "$countindex".id)
|
2022-04-13 17:14:22 +00:00
|
|
|
echo "+$count mutes"
|
|
|
|
count=0
|
|
|
|
echo "Mutes exported"
|
|
|
|
elif [ $count -gt 0 ]; then
|
2022-04-18 06:43:25 +00:00
|
|
|
echo "$mutes" | jj -l \#.acct | delq| legacy_addr_preprocess >> "backups_$instance"/mutes.csv
|
|
|
|
offset=$(echo "$mutes" | jj "$countindex".id)
|
2022-04-13 17:14:22 +00:00
|
|
|
echo "+$count mutes"
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
2022-04-13 12:52:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
follow_api_import()
|
|
|
|
{
|
2022-04-13 20:34:03 +00:00
|
|
|
post_request "$instance_point_pleroma/follow_import" \
|
2022-04-13 16:30:59 +00:00
|
|
|
--data 'list=@restore/friends.csv'
|
2022-04-13 12:52:25 +00:00
|
|
|
}
|
2022-04-13 17:14:22 +00:00
|
|
|
|
|
|
|
blocks_api_import()
|
|
|
|
{
|
2022-04-13 20:34:03 +00:00
|
|
|
post_request "$instance_point_pleroma/blocks_import" \
|
2022-04-13 17:14:22 +00:00
|
|
|
--data 'list=@restore/blocks.csv'
|
|
|
|
}
|
|
|
|
|
|
|
|
mutes_api_import()
|
|
|
|
{
|
2022-04-13 20:34:03 +00:00
|
|
|
post_request "$instance_point_pleroma/mutes_import" \
|
2022-04-13 17:14:22 +00:00
|
|
|
--data 'list=@restore/mutes.csv'
|
|
|
|
}
|
2022-04-13 12:52:25 +00:00
|
|
|
#[MIGRATION SECTION END]
|
|
|
|
|
2022-04-13 16:30:59 +00:00
|
|
|
account_api_me()
|
|
|
|
{
|
2022-04-18 06:43:25 +00:00
|
|
|
default_curl_opt "$instance_point/accounts/verify_credentials"
|
2022-04-13 16:30:59 +00:00
|
|
|
}
|
|
|
|
|
2022-04-13 12:52:25 +00:00
|
|
|
followings_api_get()
|
|
|
|
{
|
2022-04-13 16:30:59 +00:00
|
|
|
default_curl_opt "$instance_point/accounts/$1/following?limit=40&max_id=$offset"
|
2022-04-13 12:52:25 +00:00
|
|
|
}
|
2022-04-11 19:34:04 +00:00
|
|
|
|
2022-04-14 19:14:43 +00:00
|
|
|
followings_menu()
|
|
|
|
{
|
|
|
|
account_info=$(account_api_me)
|
2022-04-18 06:43:25 +00:00
|
|
|
acc_id=$(echo "$account_info" | jj id)
|
|
|
|
acc_following_count=$(echo "$account_info" | jj following_count)
|
2022-04-14 19:14:43 +00:00
|
|
|
echo "Followers: $acc_following_count"
|
|
|
|
sub_menu_lvl=1
|
|
|
|
while [ $sub_menu_lvl -eq 1 ]; do
|
2022-04-18 06:43:25 +00:00
|
|
|
followings=$(followings_api_get "$acc_id")
|
|
|
|
accts=$(echo "$followings" | jj -l \#.acct | nl -s: -v0 -w1)
|
2022-04-14 19:14:43 +00:00
|
|
|
|
|
|
|
choice=$(echo "Main menu\n$accts\nNext" | fzy)
|
|
|
|
case $choice in
|
|
|
|
"Main menu") sub_menu_lvl=0 ;;
|
2022-04-18 06:43:25 +00:00
|
|
|
"Next") offset=$(echo "$followings" | jj $(expr $(echo "$followings" | jj \#) - 1).id) ;;
|
2022-04-14 19:14:43 +00:00
|
|
|
*)
|
2022-04-18 06:43:25 +00:00
|
|
|
index=$(echo "$choice" | cut -f 1 -d:)
|
|
|
|
statuses_view_menu "$(echo "$followings" | jj "$index".acct)"
|
2022-04-14 19:14:43 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-13 17:14:22 +00:00
|
|
|
blocks_api_get()
|
|
|
|
{
|
|
|
|
default_curl_opt "$instance_point/blocks?limit=40&max_id=$offset"
|
|
|
|
}
|
|
|
|
|
|
|
|
mutes_api_get()
|
|
|
|
{
|
|
|
|
default_curl_opt "$instance_point/mutes?limit=40&max_id=$offset"
|
|
|
|
}
|
|
|
|
|
2022-04-12 23:15:25 +00:00
|
|
|
thread_api_statuses()
|
|
|
|
{
|
|
|
|
default_curl_opt "$instance_point/statuses/$1/context"
|
|
|
|
}
|
|
|
|
|
2022-04-14 15:42:47 +00:00
|
|
|
html_to_txt_render()
|
|
|
|
{
|
|
|
|
sed -e "s/<br[^>]*>/\n/g ; s/<p[^>]*>/\n/g ; s/<[^>]*>//g ; s/>*/>/g ; s/<*/</g ; s/"/\"/g ; s/'/'/g"
|
|
|
|
}
|
|
|
|
|
|
|
|
delq()
|
|
|
|
{
|
|
|
|
sed 's/"//g'
|
|
|
|
}
|
|
|
|
|
|
|
|
delqse()
|
|
|
|
{
|
|
|
|
sed 's/^"//g; s/"$//g'
|
|
|
|
}
|
|
|
|
|
2022-04-14 19:14:43 +00:00
|
|
|
statuses_api_account()
|
|
|
|
{
|
2022-04-15 15:52:28 +00:00
|
|
|
default_curl_opt "$instance_point/accounts/$1/statuses?limit=$max_statuses&max_id=$2&min_id=$3"
|
2022-04-15 07:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
status_api_one()
|
|
|
|
{
|
|
|
|
default_curl_opt "$instance_point/statuses/$1"
|
2022-04-14 19:14:43 +00:00
|
|
|
}
|
|
|
|
|
2022-04-14 22:28:33 +00:00
|
|
|
statuses_render()
|
|
|
|
{
|
2022-04-14 23:02:55 +00:00
|
|
|
if [ "$reversed_statuses" = 'true' ]; then
|
2022-04-18 06:43:25 +00:00
|
|
|
ids_massive=$(echo "$ids_massive" | tr ' ' '\n' | tac | tr '\n' ' ')
|
2022-04-14 23:02:55 +00:00
|
|
|
fi
|
2022-04-14 22:28:33 +00:00
|
|
|
for i in $ids_massive; do
|
|
|
|
status=$(echo "$jsonmassive" | jj "#[id=$i]")
|
2022-04-18 06:43:25 +00:00
|
|
|
reblog=$(echo "$status" | jj reblog.id)
|
2022-04-19 07:49:53 +00:00
|
|
|
if [ "$hide_reblogs" = 'true' ] && [ -n "$reblog" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2022-04-19 08:06:21 +00:00
|
|
|
sensitive=$(echo "$status" | jj sensitive)
|
|
|
|
if [ "$enabled_nsfw" = 'false' ] && [ "$sensitive" = 'true' ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2022-04-19 07:49:53 +00:00
|
|
|
whoacct=$(echo "$status" | jj account.acct)
|
2022-04-18 06:43:25 +00:00
|
|
|
reblogacct=$(echo "$status" | jj reblog.account.acct)
|
|
|
|
uri=$(echo "$status" | jj uri)
|
|
|
|
id_status=$(echo "$status" | jj id)
|
|
|
|
dateutc=$(echo "$status" | jj created_at)
|
|
|
|
reply_to_id=$(echo "$status" | jj in_reply_to_id)
|
|
|
|
visibility_status=$(echo "$status" | jj visibility)
|
|
|
|
echo "| $(date -d "$dateutc" "$format_time") $visibility_status $whoacct"
|
2022-04-15 17:05:15 +00:00
|
|
|
echo "| <$id_status> $uri"
|
2022-04-14 22:28:33 +00:00
|
|
|
if [ -n "$reply_to_id" ]; then
|
2022-04-15 17:05:15 +00:00
|
|
|
echo "| Reply to: $reply_to_id"
|
2022-04-14 22:28:33 +00:00
|
|
|
fi
|
|
|
|
if [ -n "$reblog" ]; then
|
2022-04-15 21:38:58 +00:00
|
|
|
echo "| $boost_symbol $reblog $reblogacct"
|
2022-04-18 20:54:01 +00:00
|
|
|
id_status="$reblog"
|
2022-04-14 22:28:33 +00:00
|
|
|
fi
|
|
|
|
spoiler_text=$(echo "$status" | jj spoiler_text)
|
|
|
|
if [ -n "$spoiler_text" ]; then
|
|
|
|
echo "#[$spoiler_text]"
|
|
|
|
fi
|
2022-04-19 08:06:21 +00:00
|
|
|
if [ "$sensitive" = 'true' ]; then
|
|
|
|
echo '[NSFW]'
|
|
|
|
fi
|
2022-04-14 22:28:33 +00:00
|
|
|
echo "$status" | jj -r content | delqse | html_to_txt_render
|
2022-04-18 06:43:25 +00:00
|
|
|
attachments=$(echo "$status" | jj -l media_attachments.#.remote_url | delq)
|
2022-04-14 22:28:33 +00:00
|
|
|
if [ -n "$attachments" ]; then
|
|
|
|
echo "#EXTINF:-1, $uri" >> attachments.m3u8
|
2022-04-15 18:18:30 +00:00
|
|
|
echo '[Attachments:]'
|
|
|
|
echo "$attachments" | tee -a attachments.m3u8
|
2022-04-14 22:28:33 +00:00
|
|
|
fi
|
2022-04-15 17:05:15 +00:00
|
|
|
echo "$statuses_separator"
|
2022-04-18 20:54:01 +00:00
|
|
|
if [ "$per_status_mode" = 'true' ]; then
|
|
|
|
next=0
|
|
|
|
force_stop=0
|
|
|
|
while [ "$next" -eq 0 ]; do
|
|
|
|
per_status_menu=$(echo 'Next\nMedia\nShare and favorite\nShare\nFavorite\nReply\nBack' | fzy)
|
|
|
|
case "$per_status_menu" in
|
|
|
|
"Next") next=1; clear ;;
|
|
|
|
"Media")
|
|
|
|
for one_media in $attachments; do
|
|
|
|
mpv "$one_media"
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
"Share and favorite") share_and_favorite_mode "$id_status" ;;
|
|
|
|
"Share") share_api_status "$id_status" ;;
|
|
|
|
"Favorite") favorite_api_status "$id_status" ;;
|
|
|
|
"Reply") reply_mode "$id_status" ;;
|
|
|
|
"Back") next=1; force_stop=1 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
if [ "$force_stop" -eq 1 ]; then break; fi
|
|
|
|
fi
|
2022-04-14 22:28:33 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-15 15:52:28 +00:00
|
|
|
statuses_view_menu()
|
|
|
|
{
|
|
|
|
sub_menu_lvl=2
|
2022-04-18 06:43:25 +00:00
|
|
|
json=$(statuses_api_account "$1")
|
2022-04-15 15:52:28 +00:00
|
|
|
while [ $sub_menu_lvl -eq 2 ]; do
|
|
|
|
clear
|
|
|
|
echo "[Statuses $1]"
|
2022-04-18 06:43:25 +00:00
|
|
|
ids_massive=$(echo "$json" | jj -l \#.id | delq)
|
2022-04-15 15:52:28 +00:00
|
|
|
jsonmassive=$json
|
|
|
|
statuses_render
|
2022-04-16 10:39:07 +00:00
|
|
|
menustatuses=$(echo 'Prev\nNext\nReply\nShare\nFavorite\nShare and favorite\nThread\nBack' | fzy)
|
2022-04-15 15:52:28 +00:00
|
|
|
case "$menustatuses" in
|
|
|
|
"Back") sub_menu_lvl=1 ;;
|
|
|
|
"Prev")
|
2022-04-18 06:43:25 +00:00
|
|
|
indexator=$(expr $(echo "$json" | jj \#) - 1)
|
2022-04-15 15:52:28 +00:00
|
|
|
echo '#EXTM3U' > attachments.m3u8
|
|
|
|
clear
|
2022-04-18 06:43:25 +00:00
|
|
|
offset=$(echo "$json" | jj "$indexator".id)
|
|
|
|
json=$(statuses_api_account "$1" "$offset")
|
2022-04-15 15:52:28 +00:00
|
|
|
;;
|
|
|
|
"Next")
|
|
|
|
echo '#EXTM3U' > attachments.m3u8
|
|
|
|
clear
|
2022-04-18 06:43:25 +00:00
|
|
|
offset=$(echo "$json" | jj 0.id)
|
|
|
|
json=$(statuses_api_account "$1" '' "$offset")
|
2022-04-15 15:52:28 +00:00
|
|
|
;;
|
|
|
|
"Reply") reply_mode ;;
|
|
|
|
"Share") share_mode ;;
|
|
|
|
"Favorite") favourite_mode ;;
|
2022-04-16 10:39:07 +00:00
|
|
|
"Share and favorite") share_and_favorite_mode ;;
|
2022-04-15 15:52:28 +00:00
|
|
|
"Thread") thread_open ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
thread_open()
|
|
|
|
{
|
|
|
|
echo 'Input id'
|
|
|
|
read status_id
|
2022-04-18 06:43:25 +00:00
|
|
|
thread_menu "$status_id"
|
2022-04-15 15:52:28 +00:00
|
|
|
}
|
|
|
|
|
2022-04-12 23:15:25 +00:00
|
|
|
thread_menu()
|
|
|
|
{
|
|
|
|
sub_menu_lvl=2
|
2022-04-18 06:43:25 +00:00
|
|
|
jsonthread=$(thread_api_statuses "$1")
|
|
|
|
ancestors=$(echo "$jsonthread" | jj ancestors)
|
|
|
|
descendants=$(echo "$jsonthread" | jj descendants)
|
2022-04-12 23:15:25 +00:00
|
|
|
if [ '[]' != "$ancestors" ] && [ '[]' != "$descendants" ]; then
|
|
|
|
jsonthread=$(echo "$ancestors""$descendants")
|
|
|
|
elif [ '[]' != "$ancestors" ]; then
|
|
|
|
jsonthread="$ancestors"
|
|
|
|
else
|
|
|
|
jsonthread="$descendants"
|
|
|
|
fi
|
|
|
|
while [ $sub_menu_lvl -eq 2 ]; do
|
|
|
|
clear
|
|
|
|
echo '[Thread]'
|
2022-04-18 06:43:25 +00:00
|
|
|
ids_massive=$(echo "$jsonthread" | jj -l \#.id | delq)
|
2022-04-14 22:28:33 +00:00
|
|
|
jsonmassive=$jsonthread
|
|
|
|
statuses_render
|
2022-04-16 10:39:07 +00:00
|
|
|
menuthread=$(echo 'Back\nReply\nShare\nFavorite\nShare and favorite' | fzy)
|
2022-04-12 23:15:25 +00:00
|
|
|
case "$menuthread" in
|
2022-04-14 22:28:33 +00:00
|
|
|
"Back") sub_menu_lvl=1 ;;
|
2022-04-15 15:52:28 +00:00
|
|
|
"Reply") reply_mode ;;
|
|
|
|
"Share") share_mode ;;
|
|
|
|
"Favorite") favourite_mode ;;
|
2022-04-16 10:39:07 +00:00
|
|
|
"Share and favorite") share_and_favorite_mode ;;
|
2022-04-12 23:15:25 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-11 19:34:04 +00:00
|
|
|
timeline_api()
|
|
|
|
{
|
2022-04-16 11:41:00 +00:00
|
|
|
case "$timeline" in
|
|
|
|
"home") default_curl_opt "$instance_point/timelines/home?limit=$max_statuses&max_id=$1&min_id=$2" ;;
|
|
|
|
"home/local") default_curl_opt "$instance_point/timelines/home?local=true&limit=$max_statuses&max_id=$1&min_id=$2" ;;
|
|
|
|
"favourites") default_curl_opt "$instance_point/favourites?limit=$max_statuses&max_id=$1&min_id=$2" ;;
|
|
|
|
"direct") default_curl_opt "$instance_point/timelines/direct?limit=$max_statuses&max_id=$1&min_id=$2" ;;
|
|
|
|
"public") default_curl_opt "$instance_point/timelines/public?limit=$max_statuses&max_id=$1&min_id=$2" ;;
|
|
|
|
"local") default_curl_opt "$instance_point/timelines/public?local=true&limit=$max_statuses&max_id=$1&min_id=$2" ;;
|
|
|
|
esac
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
timeline_menu()
|
|
|
|
{
|
|
|
|
json=$(timeline_api)
|
|
|
|
sub_menu_lvl=1
|
|
|
|
echo '#EXTM3U' > attachments.m3u8
|
2022-04-18 20:54:01 +00:00
|
|
|
if [ "$per_status_mode" = 'true' ]; then
|
|
|
|
menuentryes='Prev\nNext\nMain menu'
|
|
|
|
else
|
|
|
|
menuentryes='Prev\nNext\nReply\nShare\nFavorite\nShare and favorite\nThread\nMain menu'
|
|
|
|
fi
|
2022-04-11 19:34:04 +00:00
|
|
|
while [ $sub_menu_lvl -eq 1 ]; do
|
2022-04-18 06:43:25 +00:00
|
|
|
ids_massive=$(echo "$json" | jj -l \#.id | delq)
|
2022-04-14 22:28:33 +00:00
|
|
|
jsonmassive=$json
|
|
|
|
statuses_render
|
2022-04-18 20:54:01 +00:00
|
|
|
menu=$(echo "$menuentryes" | fzy)
|
2022-04-11 19:34:04 +00:00
|
|
|
case $menu in
|
|
|
|
"Prev")
|
2022-04-18 06:43:25 +00:00
|
|
|
indexator=$(expr $(echo "$json" | jj \#) - 1)
|
2022-04-11 19:34:04 +00:00
|
|
|
echo '#EXTM3U' > attachments.m3u8
|
|
|
|
clear
|
2022-04-18 06:43:25 +00:00
|
|
|
offset=$(echo "$json" | jj "$indexator".id)
|
|
|
|
json=$(timeline_api "$offset")
|
2022-04-11 19:34:04 +00:00
|
|
|
;;
|
|
|
|
"Next")
|
|
|
|
echo '#EXTM3U' > attachments.m3u8
|
|
|
|
clear
|
2022-04-18 06:43:25 +00:00
|
|
|
offset=$(echo "$json" | jj 0.id)
|
|
|
|
json=$(timeline_api '' "$offset")
|
2022-04-11 19:34:04 +00:00
|
|
|
;;
|
2022-04-15 15:52:28 +00:00
|
|
|
"Reply") reply_mode ;;
|
|
|
|
"Share") share_mode ;;
|
|
|
|
"Favorite") favourite_mode ;;
|
2022-04-16 10:39:07 +00:00
|
|
|
"Share and favorite") share_and_favorite_mode ;;
|
2022-04-15 15:52:28 +00:00
|
|
|
"Thread") thread_open ;;
|
|
|
|
"Main menu") sub_menu_lvl=0 ;;
|
2022-04-11 19:34:04 +00:00
|
|
|
esac
|
2022-04-14 22:28:33 +00:00
|
|
|
done
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
|
2022-04-15 15:52:28 +00:00
|
|
|
reply_mode()
|
|
|
|
{
|
2022-04-18 20:54:01 +00:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
reply_status=$(status_api_one "$1")
|
|
|
|
else
|
|
|
|
echo 'Input id'
|
|
|
|
read status_id
|
|
|
|
reply_status=$(status_api_one "$status_id")
|
|
|
|
fi
|
2022-04-15 15:52:28 +00:00
|
|
|
if [ "$quoting_reply" = 'true' ]; then
|
2022-04-17 00:06:20 +00:00
|
|
|
echo "$reply_status" | jj content | html_to_txt_render | sed 's/^/> /' > tmp_status.md
|
2022-04-15 15:52:28 +00:00
|
|
|
fi
|
2022-04-17 00:06:20 +00:00
|
|
|
if [ "$copy_mentions" = 'true' ]; then
|
2022-04-19 11:47:53 +00:00
|
|
|
mentions_reply=$(echo "$reply_status" | jj -l 'mentions.#.acct' | delq | legacy_addr_preprocess)
|
|
|
|
mentions_reply="$mentions_reply\n"
|
|
|
|
acct_selfstatus=$(echo "$reply_status" | jj account.acct | legacy_addr_preprocess)
|
|
|
|
mentions_reply=$(echo "$mentions_reply""$acct_selfstatus" | sort -u | tr '\n' ',' | sed -e 's/,$//g; s/^,//g')
|
2022-04-17 00:06:20 +00:00
|
|
|
fi
|
2022-04-18 20:54:01 +00:00
|
|
|
write_status_menu "$(echo "$reply_status" | jj id)"
|
2022-04-15 15:52:28 +00:00
|
|
|
}
|
|
|
|
|
2022-04-16 10:39:07 +00:00
|
|
|
share_and_favorite_mode()
|
|
|
|
{
|
2022-04-18 20:54:01 +00:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
share_api_status "$1"
|
|
|
|
echo "$http_code"
|
|
|
|
favorite_api_status "$1"
|
|
|
|
echo "$http_code"
|
|
|
|
else
|
|
|
|
echo 'Input id (s - stop)'
|
|
|
|
shareandfavmode=1
|
|
|
|
while [ $shareandfavmode -eq 1 ]; do
|
|
|
|
read status_id
|
|
|
|
if [ "$status_id" = 's' ]; then
|
|
|
|
shareandfavmode=0
|
|
|
|
else
|
|
|
|
share_api_status "$status_id"
|
|
|
|
echo "$http_code"
|
|
|
|
favorite_api_status "$status_id"
|
|
|
|
echo "$http_code"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2022-04-16 10:39:07 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 22:02:16 +00:00
|
|
|
share_api_status()
|
|
|
|
{
|
2022-04-18 06:43:25 +00:00
|
|
|
post_request -w "%{http_code}" --url "$instance_point/statuses/$1/reblog" --output /dev/null
|
2022-04-11 22:02:16 +00:00
|
|
|
}
|
|
|
|
|
2022-04-15 15:52:28 +00:00
|
|
|
share_mode()
|
|
|
|
{
|
|
|
|
echo 'Input id (s - stop)'
|
|
|
|
sharemode=1
|
|
|
|
while [ $sharemode -eq 1 ]; do
|
|
|
|
read status_id
|
|
|
|
if [ "$status_id" = 's' ]; then
|
|
|
|
sharemode=0
|
|
|
|
else
|
2022-04-18 06:43:25 +00:00
|
|
|
share_api_status "$status_id"
|
|
|
|
echo "$http_code"
|
2022-04-15 15:52:28 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:26:06 +00:00
|
|
|
favorite_api_status()
|
|
|
|
{
|
2022-04-18 06:43:25 +00:00
|
|
|
post_request -w "%{http_code}" --url "$instance_point/statuses/$1/favourite" --output /dev/null
|
2022-04-14 14:26:06 +00:00
|
|
|
}
|
|
|
|
|
2022-04-15 15:52:28 +00:00
|
|
|
favourite_mode()
|
|
|
|
{
|
|
|
|
echo 'Input id (s - stop)'
|
|
|
|
favoritemode=1
|
|
|
|
while [ $favoritemode -eq 1 ]; do
|
|
|
|
read status_id
|
|
|
|
if [ "$status_id" = 's' ]; then
|
|
|
|
favoritemode=0
|
|
|
|
else
|
2022-04-18 06:43:25 +00:00
|
|
|
favorite_api_status "$status_id"
|
|
|
|
echo "$http_code"
|
2022-04-15 15:52:28 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-11 19:34:04 +00:00
|
|
|
write_api_status()
|
|
|
|
{
|
2022-04-13 20:34:03 +00:00
|
|
|
if [ -n "$mediaattach" ]; then
|
|
|
|
media=$(upload_api_media | jj id)
|
2022-04-18 06:43:25 +00:00
|
|
|
post_request -w "%{http_code}" --url "$instance_point"/statuses \
|
2022-04-13 20:34:03 +00:00
|
|
|
--data-urlencode "status=$1" \
|
|
|
|
--data-urlencode "content_type=$content_type" \
|
|
|
|
--data-urlencode "visibility=$status_visibility" \
|
|
|
|
--data-urlencode "in_reply_to_id=$replyto" \
|
|
|
|
--data-urlencode "media_ids[]=$media" \
|
2022-04-17 00:06:20 +00:00
|
|
|
--data-urlencode "to[]=$mentions_reply" \
|
2022-04-13 20:34:03 +00:00
|
|
|
--output /dev/null
|
2022-04-18 06:43:25 +00:00
|
|
|
echo "$http_code"
|
2022-04-13 20:34:03 +00:00
|
|
|
else
|
2022-04-18 06:43:25 +00:00
|
|
|
post_request -w "%{http_code}" --url "$instance_point"/statuses \
|
2022-04-13 20:34:03 +00:00
|
|
|
--data-urlencode "status=$1" \
|
|
|
|
--data-urlencode "content_type=$content_type" \
|
|
|
|
--data-urlencode "visibility=$status_visibility" \
|
|
|
|
--data-urlencode "in_reply_to_id=$replyto" \
|
2022-04-17 00:06:20 +00:00
|
|
|
--data-urlencode "to[]=$mentions_reply" \
|
2022-04-13 20:34:03 +00:00
|
|
|
--output /dev/null
|
2022-04-18 06:43:25 +00:00
|
|
|
echo "$http_code"
|
2022-04-13 20:34:03 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
upload_api_media()
|
|
|
|
{
|
2022-04-18 06:43:25 +00:00
|
|
|
post_request --url "$instance_point"/media \
|
2022-04-13 20:34:03 +00:00
|
|
|
--form "file=$mediaattach"
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
write_status_menu()
|
|
|
|
{
|
|
|
|
touch tmp_status.md
|
|
|
|
content_type="$default_content_type"
|
|
|
|
status_visibility="$default_visibility"
|
2022-04-13 10:50:56 +00:00
|
|
|
replyto=$1
|
2022-04-13 20:34:03 +00:00
|
|
|
mediaattach=
|
2022-04-13 22:45:02 +00:00
|
|
|
http_code=
|
2022-04-14 10:08:43 +00:00
|
|
|
if [ -n "$sub_menu_lvl" ]; then
|
|
|
|
sub_menu_lvl=2
|
|
|
|
level=2
|
|
|
|
else
|
|
|
|
sub_menu_lvl=1
|
|
|
|
level=1
|
|
|
|
fi
|
|
|
|
while [ $sub_menu_lvl -eq $level ]; do
|
2022-04-11 19:34:04 +00:00
|
|
|
clear
|
|
|
|
echo 'Status:'
|
|
|
|
cat tmp_status.md
|
|
|
|
echo '\==========/'
|
|
|
|
echo "Chars: $(cat tmp_status.md | wc -m)"
|
|
|
|
echo "Visiblity: $status_visibility"
|
|
|
|
echo "Content type: $content_type"
|
2022-04-17 00:06:20 +00:00
|
|
|
if [ -n "$mentions_reply" ]; then
|
|
|
|
echo "Mentions: $mentions_reply"
|
|
|
|
fi
|
2022-04-13 10:50:56 +00:00
|
|
|
if [ -n "$replyto" ]; then
|
|
|
|
echo "Reply to: $replyto"
|
|
|
|
fi
|
2022-04-13 20:34:03 +00:00
|
|
|
if [ -n "$mediaattach" ]; then
|
|
|
|
echo "Attachments: $mediaattach"
|
|
|
|
fi
|
2022-04-13 22:45:02 +00:00
|
|
|
if [ -n "$http_code" ]; then
|
2022-04-13 20:34:03 +00:00
|
|
|
echo "Send state: $http_code"
|
|
|
|
fi
|
2022-04-15 07:53:57 +00:00
|
|
|
wrirepostmenu=$(echo "Edit\nSend\nAdd attach\nChange type\nVisiblity\nReset\nBack\nMain menu" | fzy)
|
2022-04-11 19:34:04 +00:00
|
|
|
case $wrirepostmenu in
|
2022-04-15 07:53:57 +00:00
|
|
|
"Edit") $EDITOR tmp_status.md ;;
|
2022-04-13 20:34:03 +00:00
|
|
|
"Send") http_code=$(write_api_status "$(cat tmp_status.md)") ;;
|
|
|
|
"Add attach")
|
|
|
|
echo 'Input path to attach (ex. @image.png or @/full/path/to/attach.png)'
|
|
|
|
read mediaattach
|
|
|
|
;;
|
2022-04-11 19:34:04 +00:00
|
|
|
"Change type") content_type=$(echo 'text/plain\ntext/markdown\ntext/html' | fzy) ;;
|
|
|
|
"Visiblity")
|
|
|
|
status_visibility=$(echo 'public\nunlisted\nlocal\nprivate\ndirect\nlist' | fzy)
|
|
|
|
;;
|
2022-04-17 00:06:20 +00:00
|
|
|
"Reset")
|
|
|
|
echo > tmp_status.md
|
|
|
|
mentions_reply=
|
|
|
|
;;
|
2022-04-14 10:08:43 +00:00
|
|
|
"Back") sub_menu_lvl=$(expr $level - 1) ;;
|
2022-04-11 19:34:04 +00:00
|
|
|
"Main menu") sub_menu_lvl=0 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-12 14:27:36 +00:00
|
|
|
notif_menu()
|
|
|
|
{
|
|
|
|
sub_menu_lvl=1
|
|
|
|
clrnotif='Clear all notifications'
|
|
|
|
json=$(notif_api_get_all)
|
|
|
|
while [ $sub_menu_lvl -eq 1 ]; do
|
|
|
|
clear
|
2022-04-18 06:43:25 +00:00
|
|
|
count_new_notif=$(echo "$json" | jj -l '#[pleroma.is_seen=false]#.pleroma.is_seen' | wc -w)
|
2022-04-17 19:23:18 +00:00
|
|
|
echo "New notifications: $count_new_notif"
|
2022-04-18 06:43:25 +00:00
|
|
|
for i in $(echo "$json" | jj -l \#.id); do
|
|
|
|
date_utc=$(echo "$json" | jj \#[id="$i"].created_at)
|
2022-04-12 14:27:36 +00:00
|
|
|
date -d "$date_utc" "$format_time"
|
2022-04-18 06:43:25 +00:00
|
|
|
acct=$(echo "$json" | jj \#[id="$i"].account.acct)
|
|
|
|
status_id=$(echo "$json" | jj \#[id="$i"].status.id)
|
|
|
|
typenotif=$(echo "$json" | jj \#[id="$i"].type)
|
2022-04-17 19:23:18 +00:00
|
|
|
echo "<$status_id> $typenotif <- $acct"
|
2022-04-18 06:43:25 +00:00
|
|
|
echo "$json" | jj -r \#[id="$i"].status.content | delqse | html_to_txt_render
|
2022-04-12 14:27:36 +00:00
|
|
|
echo '___'
|
|
|
|
done
|
2022-04-17 19:23:18 +00:00
|
|
|
menu_choice=$(echo "Main menu\nRead\nRefresh\n$clrnotif" | fzy)
|
2022-04-12 14:27:36 +00:00
|
|
|
case "$menu_choice" in
|
|
|
|
"Main menu") sub_menu_lvl=0 ;;
|
2022-04-17 19:23:18 +00:00
|
|
|
"Read")
|
2022-04-18 06:43:25 +00:00
|
|
|
notif_api_read "$(echo "$json" | jj 0.id)"
|
2022-04-17 19:23:18 +00:00
|
|
|
json=$(notif_api_get_all)
|
|
|
|
;;
|
2022-04-12 14:27:36 +00:00
|
|
|
"Refresh") json=$(notif_api_get_all) ;;
|
|
|
|
"$clrnotif") notif_api_remove_all && json=$(notif_api_get_all) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-11 19:34:04 +00:00
|
|
|
notif_api_get_all()
|
|
|
|
{
|
2022-04-17 19:23:18 +00:00
|
|
|
default_curl_opt "$instance_point/notifications?limit=$max_statuses" | jj -p
|
|
|
|
}
|
|
|
|
|
|
|
|
notif_api_read()
|
|
|
|
{
|
|
|
|
post_request --url "$instance_point/pleroma/notifications/read" \
|
|
|
|
--data-urlencode "max_id=$1" \
|
|
|
|
--output /dev/null
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
notif_api_remove_all()
|
|
|
|
{
|
2022-04-18 06:43:25 +00:00
|
|
|
post_request --url "$instance_point"/notifications/clear
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
menu_write_status='Write status'
|
|
|
|
menu_timeline='Timelines'
|
2022-04-12 14:27:36 +00:00
|
|
|
notif='Notifications'
|
2022-04-14 19:14:43 +00:00
|
|
|
followingsmenu='Followings'
|
2022-04-11 19:34:04 +00:00
|
|
|
authmake='Auth'
|
2022-04-13 17:50:48 +00:00
|
|
|
backup_restore='Backup/Restore'
|
2022-04-11 19:34:04 +00:00
|
|
|
switchinstance='Switch instance'
|
|
|
|
Exit='Exit'
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
if [ -n "$auth" ]; then
|
2022-04-14 19:14:43 +00:00
|
|
|
main_menu=$(echo "$menu_write_status\n$menu_timeline\n$notif\n$followingsmenu\n$backup_restore\n$switchinstance\n$Exit" | fzy)
|
2022-04-11 19:34:04 +00:00
|
|
|
else
|
2022-04-14 09:15:55 +00:00
|
|
|
main_menu=$(echo "$authmake\n$menu_timeline\n$switchinstance\n$Exit" | fzy)
|
2022-04-11 19:34:04 +00:00
|
|
|
fi
|
|
|
|
case $main_menu in
|
|
|
|
"$menu_write_status") write_status_menu ;;
|
|
|
|
"$menu_timeline")
|
2022-04-16 11:41:00 +00:00
|
|
|
timeline=$(echo 'home\nhome/local\nfavourites\ndirect\nlocal\npublic' | fzy)
|
2022-04-11 19:34:04 +00:00
|
|
|
timeline_menu
|
|
|
|
;;
|
2022-04-12 14:27:36 +00:00
|
|
|
"$notif") notif_menu ;;
|
2022-04-14 19:14:43 +00:00
|
|
|
"$followingsmenu") followings_menu ;;
|
2022-04-13 17:50:48 +00:00
|
|
|
"$backup_restore") backup_restore_menu ;;
|
2022-04-11 19:34:04 +00:00
|
|
|
"$switchinstance")
|
|
|
|
empty=0
|
|
|
|
case $(echo 'Recently used\nChoice from list\nManual input' | fzy) in
|
|
|
|
"Recently used")
|
|
|
|
if [ -s $instance_hist ]; then
|
|
|
|
touch $instance_hist && instance=$(cat $instance_hist | fzy)
|
|
|
|
else
|
|
|
|
echo 'No recently used instances...'
|
|
|
|
empty=1
|
|
|
|
fi ;;
|
|
|
|
|
|
|
|
"Choice from list") instance=$(jj -l -i config.json public_list_instances | sed 's/"//g' | fzy) ;;
|
|
|
|
|
|
|
|
"Manual input") echo "Type instance (ex. $instance):" && read instance ;;
|
|
|
|
esac
|
|
|
|
if [ $empty -eq 0 ]; then
|
2022-04-18 06:43:25 +00:00
|
|
|
echo "$instance" >> $instance_hist
|
2022-04-11 19:34:04 +00:00
|
|
|
cat $instance_hist | sort | uniq | tee $instance_hist 1>>/dev/null
|
|
|
|
export instance
|
|
|
|
export instance_point="https://$instance/api/v1"
|
|
|
|
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
|
|
|
if [ "$conf_instance_state" = 'Permanent' ]; then
|
2022-04-18 06:43:25 +00:00
|
|
|
jj -i config.json instance -v "$instance" -o config.json
|
2022-04-11 19:34:04 +00:00
|
|
|
else
|
|
|
|
echo ''
|
|
|
|
fi
|
|
|
|
clear
|
2022-04-18 06:43:25 +00:00
|
|
|
auth="$(jj -i .auth.json "$(echo "$instance" | sed 's/\./\\\./g')")"
|
2022-04-11 19:34:04 +00:00
|
|
|
echo "Instance: $instance"
|
|
|
|
if [ -n "$auth" ]; then
|
|
|
|
default_curl_opt()
|
|
|
|
{
|
2022-04-13 23:51:46 +00:00
|
|
|
curl -s --compressed -H "Authorization: Bearer $auth" "$@"
|
|
|
|
}
|
|
|
|
post_request()
|
|
|
|
{
|
|
|
|
curl -s --compressed -X POST -H "Authorization: Bearer $auth" "$@"
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
echo '+Authorized account+'
|
|
|
|
else
|
|
|
|
default_curl_opt()
|
|
|
|
{
|
2022-04-18 06:43:25 +00:00
|
|
|
curl -s --compressed "$1"
|
2022-04-11 19:34:04 +00:00
|
|
|
}
|
|
|
|
echo 'Please make auth and restart'
|
|
|
|
fi
|
|
|
|
fi ;;
|
|
|
|
"$authmake") auth_api_get_token ;;
|
|
|
|
"$Exit") exit 0 ;;
|
|
|
|
esac
|
|
|
|
done
|