Compare commits

..

2 Commits

5 changed files with 39 additions and 9 deletions

View File

@ -2,7 +2,7 @@
#Well, it seems to work now.
pkgname=clemmy
pkgver=0.1.2
pkgver=0.1.3
pkgrel=1
pkgdesc='A pure bash client for lemmy, with multiaccount support.'
arch=('any')

2
api.sh
View File

@ -1,4 +1,4 @@
baseurl(){ echo "https://$INSTANCE/api/v3/"; } # This needs to be a function so updates to INSTANCE affect it. This is a very old bug lmao
baseurl(){ if [ -z $INSEC ]; then sec=s; fi; echo "http$sec://$INSTANCE/api/v3/"; } # This needs to be a function so updates to INSTANCE affect it. This is a very old bug lmao
#Generics
get(){ curl -s "$(baseurl)$1?${*:3}" | jq "$2"; }

View File

@ -9,10 +9,10 @@ source $imps/creds.sh
source $imps/utils.sh
while getopts "a:hi:v" o;do case "${o}" in
a) INSTANCE=${insts[$OPTARG]}; TOKE=${tokes[$OPTARG]};;
a) select_account $OPTARG;;
i) INSTANCE=$OPTARG;;
h) echo $actions; exit;;
v) echo 0.1.2; exit;;
v) echo 0.1.3; exit;;
esac done
shift $((OPTIND-1))

25
commands/admin.sh Normal file
View File

@ -0,0 +1,25 @@
pendcount()
{
getauth "admin/registration_application/count" ".registration_applications"
}
pending()
{
applications=$(getauth "admin/registration_application/list" ".registration_applications" "unread_only=true")
i=0
app=$(jq .[$i] <<< "$applications")
while [ -n "$app" ]; do
appid=$(jq -r .registration_application.id <<< "$app")
jq '.registration_application.id, (.creator | .name,.published,.bio,"bot: "+.bot_account,"matrix: "+.matrix_user_id,.avatar,.banner), "captcha: "+.registration_application.answer' <<< "$app"
ans= # Better make sure this resets lol
while [ ! ans = 'y' -a ! ans = 'n' -a ! ans = 's' ]; do
namedget ans "Accept? (y)es (n)o (s)kip"
done
case $ans in
y) put "admin/registration_application/approve" "{\"id\":$appid,\"approve\":true}";;
n) namedget rejected "Why not?" true; put "admin/registration_application/approve" "{\"id\":$appid,\"deny_reason\":\"$rejected\",\"approve\":false}";;
esac
done
}
curl -iX PUT $INSTANCE/api/v3/admin/registration_application/approve --json "{\"id\":8,\"auth\":\"$TOKE\",\"approve\":true}"

View File

@ -11,11 +11,16 @@ if [ ! -f ~/.config/clemmy/accounts.csv ]; then
exit
fi
accs=$(cat ~/.config/clemmy/accounts.csv)
accsr=$(cat ~/.config/clemmy/accounts.csv)
i=0
for line in ${accs[*]}; do
IFS=, read insts[$i] tokes[$i] <<< $line
for line in ${accsr[*]}; do
accs[$i]="$line"
i=$((i+1))
done
INSTANCE=${insts[0]}
TOKE=${tokes[0]}
select_account()
{
IFS=, read INSTANCE TOKE INSEC <<< "${accs[$1]}"
}
select_account 0