ai/at
ai/at
1
0
This commit is contained in:
syui 2025-02-23 14:50:05 +09:00
parent c2dc0b72d5
commit c6ccde30cb
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56

View File

@ -1,5 +1,5 @@
function at-env() {
host=bsky.social
host=https://bsky.social
handle_syui=syui.ai
handle_yui=yui.syui.ai
did_yui=did:plc:4hqjfn7m6n5hno3doamuhgef
@ -15,6 +15,7 @@ function at-env() {
d=${0:a:h}
f=~/.config/.at-zsh.json
if [ -f $f ];then
host=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"`
token=`cat $f|jq -r .accessJwt`
did=`cat $f|jq -r .did`
handle=`cat $f|jq -r .handle`
@ -103,7 +104,7 @@ function at-refresh() {
echo $f
token=`cat $f|jq -r .refreshJwt`
req=/xrpc/com.atproto.server.refreshSession
url=https://${host}${req}
url=${host}${req}
t=`curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url`
if echo $t |jq .;then
echo $t >! $f
@ -114,13 +115,13 @@ function at-cid() {
did=`at-did $1|jq -r .did`
cid=$2
req=/xrpc/com.atproto.sync.getBlob
url="https://${host}${req}?did=${did}&cid=${cid}"
url="${host}${req}?did=${did}&cid=${cid}"
curl -sL $url
}
function at-session() {
req=/xrpc/com.atproto.server.getSession
url=https://${host}${req}
url=${host}${req}
t=`curl -sL -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url`
if ! echo $t |jq .;then
echo refresh
@ -136,6 +137,6 @@ function at-profile() {
t=`at-session`
fi
req=/xrpc/app.bsky.actor.getProfile
url="https://${host}${req}?actor=$did"
url="${host}${req}?actor=$did"
curl -sL -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url|jq .
}