ai/at
ai/at
1
0
This commit is contained in:
syui 2025-04-15 08:17:15 +09:00
parent cc27f367ea
commit 246f95a00c
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
5 changed files with 95 additions and 34 deletions

View File

@ -146,7 +146,7 @@ function at-repos-social-app-patch() {
function at-repos-docker() { function at-repos-docker() {
cd $d cd $d
sudo docker compose build && sudo docker compose up -d docker compose build && docker compose up -d
} }
at-repos-env at-repos-env

View File

@ -4,6 +4,8 @@ d=${0:a:h}
source $d/src/tag.zsh source $d/src/tag.zsh
source $d/src/func.zsh source $d/src/func.zsh
source $d/src/ai/syui/game/character.zsh
source $d/src/is/syu/main.zsh
at-env at-env
case $1 in case $1 in
@ -38,29 +40,29 @@ case $1 in
at-profile at-profile
;; ;;
download-character-icon) download-character-icon)
source $d/src/ai/syui/game/character.zsh
download_character_icon download_character_icon
;; ;;
create-game-character) create-game-character)
source $d/src/ai/syui/game/character.zsh
create_game_character create_game_character
;; ;;
create-game-user) create-game-user)
source $d/src/ai/syui/game/character.zsh
create_game_user $2 create_game_user $2
;; ;;
create-item) create-system)
source $d/src/ai/syui/game/character.zsh create_system
create_item
;; ;;
get-game-user) get-game-user)
source $d/src/ai/syui/game/character.zsh
get_game_user $2 get_game_user $2
;; ;;
delete-game-user) delete-game-user)
source $d/src/ai/syui/game/character.zsh
delete_game_user $2 $3 delete_game_user $2 $3
;; ;;
verify-icon)
verify-icon
;;
self-col)
self-col
;;
*) *)
echo "${help[@]}" echo "${help[@]}"
echo "${host[@]}" echo "${host[@]}"

View File

@ -210,6 +210,7 @@ delete_game_user() {
req=com.atproto.repo.DeleteRecord req=com.atproto.repo.DeleteRecord
url=https://$pds/xrpc/$req url=https://$pds/xrpc/$req
repo=$did repo=$did
#repo=did:plc:6qyecktefllvenje24fcxnie
json="{\"collection\":\"$col\", \"rkey\":\"$rkey\", \"repo\":\"$repo\"}" json="{\"collection\":\"$col\", \"rkey\":\"$rkey\", \"repo\":\"$repo\"}"
echo $json echo $json
curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url
@ -218,9 +219,12 @@ delete_game_user() {
function create_game_user() { function create_game_user() {
col=ai.syui.game col=ai.syui.game
rkey=$1 rkey=$1
did=$did_yui did=$did
handle=$handle_yui handle=$handle
pds=bsky.social pds=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"|cut -d / -f 3`
if [ "$pds" != "syu.is" ];then
pds=bsky.social
fi
version=4 version=4
#rkey=syui #rkey=syui
#img=https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:4hqjfn7m6n5hno3doamuhgef/bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy@jpeg #img=https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:4hqjfn7m6n5hno3doamuhgef/bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy@jpeg
@ -282,8 +286,8 @@ function create_game_user() {
v1_json=" v1_json="
{ {
\"repo\": \"$handle_yui\", \"repo\": \"$handle\",
\"did\": \"$did_yui\", \"did\": \"$did\",
\"collection\": \"$col\", \"collection\": \"$col\",
\"rkey\": \"$rkey\", \"rkey\": \"$rkey\",
\"record\": { \"record\": {
@ -309,8 +313,8 @@ json_item="
json=" json="
{ {
\"repo\": \"$handle_yui\", \"repo\": \"$handle\",
\"did\": \"$did_yui\", \"did\": \"$did\",
\"collection\": \"$col\", \"collection\": \"$col\",
\"rkey\": \"$rkey\", \"rkey\": \"$rkey\",
\"record\": { \"record\": {
@ -350,32 +354,41 @@ if echo $json|jq . ;then
fi fi
} }
function create_item() { function create_system() {
col=ai.syui.item col=ai.syui.system
rkey=self rkey=self
did=$did_yui did=$did
handle=$handle_yui handle=$handle
pds=bsky.social pds=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"|cut -d / -f 3`
if [ "$pds" != "syu.is" ];then
pds=bsky.social
fi
version=1 version=1
#rkey=syui #rkey=syui
#img=https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:4hqjfn7m6n5hno3doamuhgef/bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy@jpeg #img=https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:4hqjfn7m6n5hno3doamuhgef/bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy@jpeg
req=com.atproto.repo.putRecord req=com.atproto.repo.putRecord
url=https://$pds/xrpc/$req url=https://$pds/xrpc/$req
cid=bafkreia3huw2gdenqatoobx3hcft74chced46bw4znfgepo5aenegobkri #cid=bafkreia3huw2gdenqatoobx3hcft74chced46bw4znfgepo5aenegobkri
imguri=https://cdn.bsky.app/img/feed_thumbnail/plain/$did_yui/${cid}@jpeg #imguri=https://cdn.bsky.app/img/feed_thumbnail/plain/$did_yui/${cid}@jpeg
imgurl=https://git.syui.ai/ai/ai/raw/branch/main/item/ imgurl=https://git.syui.ai/ai/ai/raw/branch/main/img/item/card
json_card=" \"id\": $id, \"name\": \"$name\", \"img\": \"${imgurl}/${id}.webp\"" json_card=" \"id\": $id, \"name\": \"$name\", \"img\": \"${imgurl}/${id}.webp\""
json_card=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/item/card.json|jq .` json_card=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/card.json|jq ".[]"`
json_weapon=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/item/weapon.json|jq .` json_weapon=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/weapon.json|jq ".[]"`
json_system=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/system.json|jq ".[]"`
json_character=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/character.json|jq ".[]"`
json_ability=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/ability.json|jq ".[]"`
json=" json="
{ {
\"repo\": \"$handle_yui\", \"repo\": \"$handle\",
\"did\": \"$did_yui\", \"did\": \"$did\",
\"collection\": \"$col\", \"collection\": \"$col\",
\"rkey\": \"$rkey\", \"rkey\": \"$rkey\",
\"record\": { \"record\": {
\"card\": ${json_card}, \"card\": ${json_card},
\"weapon\": ${json_weapon}, \"weapon\": ${json_weapon},
\"system\": ${json_system},
\"character\": ${json_character},
\"ability\": ${json_ability},
\"createdAt\": \"${created}\", \"createdAt\": \"${created}\",
\"updatedAt\": \"${created}\" \"updatedAt\": \"${created}\"
} }

View File

@ -8,21 +8,25 @@ function at-env() {
did_syui=did:plc:uqzpqmrjnptsxezjx4xuh2mn did_syui=did:plc:uqzpqmrjnptsxezjx4xuh2mn
handle=$handle_yui handle=$handle_yui
did=$did_yui did=$did_yui
created=2020-01-01T00:00:00+09:00 created=2025-04-21T00:00:00.323Z
at_uri=at://$did_yui/ai.syui.game.user/syui
docs_uri=https://docs.bsky.app/docs/api docs_uri=https://docs.bsky.app/docs/api
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} d=${0:a:h}
f=~/.config/ai/token.json f=~/.config/ai/token.json
if [ -f $f ];then if [ -f $f ];then
host=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"` host=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"|cut -d / -f 3`
token=`cat $f|jq -r .accessJwt` token=`cat $f|jq -r .accessJwt`
did=`cat $f|jq -r .did` did=`cat $f|jq -r .did`
handle=`cat $f|jq -r .handle` handle=`cat $f|jq -r .handle`
actor=$did actor=$did
fi fi
if [ "$host" = "syu.is" ];then
plc=plc.syu.is
pds=$host
fi
at_uri=at://$handle/ai.syui.game/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`
} }
function at-unset() { function at-unset() {
@ -173,3 +177,32 @@ function at-profile() {
url="${host}${req}?actor=$did" url="${host}${req}?actor=$did"
curl -sL -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url|jq . curl -sL -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url|jq .
} }
function verify-icon() {
syuisadmin_handle=ai.syu.is
syuisadmin_did=did:plc:6qyecktefllvenje24fcxnie
#rkey=
col=app.bsky.graph.verification
handle=syui.syu.is
subject=did:plc:vzsvtbtbnwn22xjqhcu3vd6y
displayName=syui
req=/xrpc/com.atproto.repo.createRecord
url=${host}${req}
json="
{
\"repo\": \"$syuisadmin_handle\",
\"did\": \"$syuisadmin_did\",
\"collection\": \"$col\",
\"record\": {
\"subject\": \"$subject\",
\"handle\": \"$handle\",
\"displayName\": \"$displayName\",
\"createdAt\": \"${created}\"
}
}"
if echo $json|jq . ;then
t=`curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url`
echo $t
fi
}

13
scpt/src/is/syu/main.zsh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/zsh
function self-col(){
col=(
ai.syui.game
ai.syui.system
)
e=${col[@]: -1}
for i in $col; do
t=`curl -sL "$pds/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=$i"`
echo $t|jq .
done
}