From b6b1e341f25ba7df682b6fdbbf73033510a17d9b Mon Sep 17 00:00:00 2001 From: syui Date: Wed, 19 Mar 2025 12:08:22 +0900 Subject: [PATCH] fix --- scpt/at.zsh | 2 +- scpt/src/ai/syui/game/character.zsh | 80 ++++++++++------------------- 2 files changed, 29 insertions(+), 53 deletions(-) diff --git a/scpt/at.zsh b/scpt/at.zsh index 8255934..49ccb63 100755 --- a/scpt/at.zsh +++ b/scpt/at.zsh @@ -47,7 +47,7 @@ case $1 in ;; create-game-user) source $d/src/ai/syui/game/character.zsh - ai_create_user $2 + create_game_user $2 ;; get-game-user) source $d/src/ai/syui/game/character.zsh diff --git a/scpt/src/ai/syui/game/character.zsh b/scpt/src/ai/syui/game/character.zsh index 1190c51..1a3f2a8 100755 --- a/scpt/src/ai/syui/game/character.zsh +++ b/scpt/src/ai/syui/game/character.zsh @@ -189,7 +189,33 @@ json="{ } -function ai_create_user() { +function get_game_user() { + rkey=$did.$pds + pds=bsky.social + if [ "$1" = "syui" ] || [ "$1" = "ai" ];then + rkey=$1 + fi + req=com.atproto.repo.getRecord + url="https://$pds/xrpc/$req?rkey=$rkey&repo=$did_yui&collection=ai.syui.game" + curl -sL $url|jq . +} + +delete_game_user() { + rkey=$2 + if [ -z "$1" ];then + col=ai.syui.game + else + col=$1 + 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 +} + +function create_game_user() { col=ai.syui.game rkey=$1 did=$did_yui @@ -306,59 +332,9 @@ if echo $json|jq . ;then echo $t|jq . f=~/ai/ue/json/v${version}_${rkey}.json if [ -f $f ];then - echo $t|jq . >! $f + get_game_user $rkey >! $f fi 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\" -#} -#}" -# -#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 } -get_game_user() { - rkey=$did.$pds - pds=bsky.social - if [ "$1" = "syui" ] || [ "$1" = "ai" ];then - rkey=$1 - fi - req=com.atproto.repo.getRecord - url="https://$pds/xrpc/$req?rkey=$rkey&repo=$did_yui&collection=ai.syui.game" - curl -sL $url|jq . -} - -delete_game_user() { - rkey=$2 - if [ -z "$1" ];then - col=ai.syui.game - else - col=$1 - 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 -}