From f11e5fff52a6c010deb47465f426708c6bce542c Mon Sep 17 00:00:00 2001 From: syui Date: Thu, 28 Nov 2024 04:42:16 +0900 Subject: [PATCH] fix --- at.zsh | 140 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/at.zsh b/at.zsh index cc39891..170ebe4 100755 --- a/at.zsh +++ b/at.zsh @@ -12,60 +12,60 @@ host=( plc.directory ) lexicon=( - com.atproto.repo.describeRepo - com.atproto.repo.getRecord - com.atproto.repo.listRecords - com.atproto.identity.resolveHandle - com.atproto.server.createSession - com.atproto.server.refreshSession + com.atproto.repo.describeRepo + com.atproto.repo.getRecord + com.atproto.repo.listRecords + com.atproto.identity.resolveHandle + com.atproto.server.createSession + com.atproto.server.refreshSession ) function at-env(){ - host=bsky.social - at_uri=at://did:plc:4hqjfn7m6n5hno3doamuhgef/ai.syui.game.user/syui - docs_uri=https://docs.bsky.app/docs/api - handle=yui.syui.ai - did=`echo $at_uri|cut -d / -f 3` - collection=`echo $at_uri|cut -d / -f 4` - rkey=`echo $at_uri|cut -d / -f 5` - d=${0:a:h} - f=~/.config/.at-zsh.json +host=bsky.social +at_uri=at://did:plc:4hqjfn7m6n5hno3doamuhgef/ai.syui.game.user/syui +docs_uri=https://docs.bsky.app/docs/api +handle=yui.syui.ai +did=`echo $at_uri|cut -d / -f 3` +collection=`echo $at_uri|cut -d / -f 4` +rkey=`echo $at_uri|cut -d / -f 5` +d=${0:a:h} +f=~/.config/.at-zsh.json } function at-uri-search(){ - if [ -n "$1" ];then - at_uri=$1 - fi - req=/xrpc/com.atproto.repo.getRecord - url=https://${host}${req} - did=`echo $at_uri|cut -d / -f 3` - collection=`echo $at_uri|cut -d / -f 4` - rkey=`echo $at_uri|cut -d / -f 5` - curl -sL "$url?repo=$did&collection=$collection&rkey=$rkey"|jq . +if [ -n "$1" ];then + at_uri=$1 +fi +req=/xrpc/com.atproto.repo.getRecord +url=https://${host}${req} +did=`echo $at_uri|cut -d / -f 3` +collection=`echo $at_uri|cut -d / -f 4` +rkey=`echo $at_uri|cut -d / -f 5` +curl -sL "$url?repo=$did&collection=$collection&rkey=$rkey"|jq . } function at-did-search(){ - if [ -n "$1" ];then - handle=$1 - fi - req=/xrpc/com.atproto.repo.describeRepo - url=https://${host}${req} - curl -sL "$url?repo=$handle"|jq . +if [ -n "$1" ];then + handle=$1 +fi +req=/xrpc/com.atproto.repo.describeRepo +url=https://${host}${req} +curl -sL "$url?repo=$handle"|jq . } function at-collection-search(){ - reverse=false - if [ -n "$1" ];then - at_uri=$1 - fi - if [ "$2" = "-r" ];then - reverse=true - fi - req=/xrpc/com.atproto.repo.listRecords - url=https://${host}${req} - did=`echo $at_uri|cut -d / -f 3` - collection=`echo $at_uri|cut -d / -f 4` - curl -sL "$url?repo=$did&collection=$collection&reverse=$reverse"|jq . +reverse=false +if [ -n "$1" ];then + at_uri=$1 +fi +if [ "$2" = "-r" ];then + reverse=true +fi +req=/xrpc/com.atproto.repo.listRecords +url=https://${host}${req} +did=`echo $at_uri|cut -d / -f 3` +collection=`echo $at_uri|cut -d / -f 4` +curl -sL "$url?repo=$did&collection=$collection&reverse=$reverse"|jq . } @@ -78,37 +78,37 @@ done } function at-login(){ - if [ -z "$1" ] || [ -z "$2" ];then - echo handle password - exit - fi - handle=$1 - password=$2 - echo $password - json="{\"identifier\":\"$handle\",\"password\":\"$password\"}" - req=/xrpc/com.atproto.server.createSession - url=https://${host}${req} - if [ ! -d ~/.config ];then - mkdir -p ~/.config - fi - t=`curl -sL -X POST -H "Content-Type: application/json" -d $json $url` - if echo $t |jq .;then - echo $t >! $f - fi - unset t password +if [ -z "$1" ] || [ -z "$2" ];then + echo handle password + exit +fi +handle=$1 +password=$2 +echo $password +json="{\"identifier\":\"$handle\",\"password\":\"$password\"}" +req=/xrpc/com.atproto.server.createSession +url=https://${host}${req} +if [ ! -d ~/.config ];then + mkdir -p ~/.config +fi +t=`curl -sL -X POST -H "Content-Type: application/json" -d $json $url` +if echo $t |jq .;then + echo $t >! $f +fi +unset t password } function at-refresh(){ - echo $f - token=`cat $f|jq -r .accessJwt` - refresh=`cat $f|jq -r .refreshJwt` - req=/xrpc/com.atproto.server.refreshSession - url=https://${host}${req} - t=`curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $refresh" $url` - if echo $t |jq .;then - echo $t >! $f - fi - unset t token refresh +echo $f +token=`cat $f|jq -r .accessJwt` +refresh=`cat $f|jq -r .refreshJwt` +req=/xrpc/com.atproto.server.refreshSession +url=https://${host}${req} +t=`curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $refresh" $url` +if echo $t |jq .;then + echo $t >! $f +fi +unset t token refresh } at-env