From a4e75204312472cf1c49442bbf671521e42e79e8 Mon Sep 17 00:00:00 2001 From: syui Date: Wed, 19 Mar 2025 09:42:15 +0900 Subject: [PATCH] fix --- scpt/at.zsh | 10 +++- scpt/src/ai/syui/game/character.zsh | 74 ++++++++++++++++++++--------- scpt/src/func.zsh | 1 + 3 files changed, 61 insertions(+), 24 deletions(-) diff --git a/scpt/at.zsh b/scpt/at.zsh index f5fd7ae..8255934 100755 --- a/scpt/at.zsh +++ b/scpt/at.zsh @@ -45,10 +45,18 @@ case $1 in source $d/src/ai/syui/game/character.zsh create_game_character ;; - ai-create-user) + create-game-user) source $d/src/ai/syui/game/character.zsh ai_create_user $2 ;; + get-game-user) + source $d/src/ai/syui/game/character.zsh + get_game_user $2 + ;; + delete-game-user) + source $d/src/ai/syui/game/character.zsh + delete_game_user $2 $3 + ;; *) echo "${help[@]}" echo "${host[@]}" diff --git a/scpt/src/ai/syui/game/character.zsh b/scpt/src/ai/syui/game/character.zsh index 8fcdb12..5f1743d 100755 --- a/scpt/src/ai/syui/game/character.zsh +++ b/scpt/src/ai/syui/game/character.zsh @@ -1,4 +1,3 @@ -echo $token character=( ai manny @@ -191,7 +190,7 @@ json="{ } function ai_create_user() { - col=ai.syui.game.user + col=ai.syui.game rkey=$1 did=$did_yui handle=$handle_yui @@ -211,6 +210,8 @@ function ai_create_user() { fi if [ "$rkey" = "syui" ];then cname=chinese + did=$did_syui + handle=syui.ai cid=bafkreidlealfybajqzwv5eoz4jshnsijc2vnktlhpw4ph47krwj6aigqby gender=male fi @@ -271,6 +272,8 @@ function ai_create_user() { \"rkey\": \"$rkey\", \"record\": { \"version\": 2, + \"did\": \"$did\", + \"handle\": \"$handle\", \"player\": { \"did\": \"$did\", \"handle\": \"$handle\", @@ -296,29 +299,54 @@ if echo $json|jq . ;then fi fi -col=ai.syui.game -rkey=self -at_uri=at://$did_yui/ai.syui.game.user/ai - -json=" -{ - \"repo\": \"$handle_yui\", - \"did\": \"$did_yui\", - \"collection\": \"$col\", - \"rkey\": \"$rkey\", - \"record\": { - \"account\": \"$at_uri\", - \"username\": \"ai\", - \"createdAt\": \"$created\" +#col=ai.syui.game +#rkey=self +#at_uri=at://$did_yui/ai.syui.game.user/ai +# +#json=" +#{ +# \"repo\": \"$handle_yui\", +# \"did\": \"$did_yui\", +# \"collection\": \"$col\", +# \"rkey\": \"$rkey\", +# \"record\": { +# \"account\": \"$at_uri\", +# \"username\": \"ai\", +# \"createdAt\": \"$created\" +#} +#}" +# +#if echo $json|jq . ;then +# echo y +# read y +# if [ "y" = "$y" ];then +# curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url +# fi +#fi } -}" -if echo $json|jq . ;then - echo y - read y - if [ "y" = "$y" ];then - curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url +get_game_user() { + rkey=$did.$pds + pds=bsky.social + if [ "$1" = "syui" ] || [ "$1" = "ai" ];then + rkey=$1 fi -fi + req=com.atproto.repo.getRecord + url="https://$pds/xrpc/$req?rkey=$rkey&repo=$did_yui&collection=ai.syui.game.user" + curl -sL $url|jq . } +delete_game_user() { + rkey=$1 + if [ -z "$2" ];then + col=ai.syui.game.user + else + col=$2 + fi + req=com.atproto.repo.DeleteRecord + url=https://$pds/xrpc/$req + repo=$did_yui + json="{\"collection\":\"$col\", \"rkey\":\"$rkey\", \"repo\":\"$repo\"}" + echo $json + curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url +} diff --git a/scpt/src/func.zsh b/scpt/src/func.zsh index df9ea6a..004cf4d 100644 --- a/scpt/src/func.zsh +++ b/scpt/src/func.zsh @@ -1,4 +1,5 @@ function at-env() { + pds=bsky.social host=https://bsky.social handle_syui=syui.ai handle_yui=yui.syui.ai