ai/at
ai/at
1
0
This commit is contained in:
syui 2025-03-19 09:42:15 +09:00
parent d990a50541
commit a4e7520431
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
3 changed files with 61 additions and 24 deletions

View File

@ -45,10 +45,18 @@ case $1 in
source $d/src/ai/syui/game/character.zsh source $d/src/ai/syui/game/character.zsh
create_game_character create_game_character
;; ;;
ai-create-user) create-game-user)
source $d/src/ai/syui/game/character.zsh source $d/src/ai/syui/game/character.zsh
ai_create_user $2 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 "${help[@]}"
echo "${host[@]}" echo "${host[@]}"

View File

@ -1,4 +1,3 @@
echo $token
character=( character=(
ai ai
manny manny
@ -191,7 +190,7 @@ json="{
} }
function ai_create_user() { function ai_create_user() {
col=ai.syui.game.user col=ai.syui.game
rkey=$1 rkey=$1
did=$did_yui did=$did_yui
handle=$handle_yui handle=$handle_yui
@ -211,6 +210,8 @@ function ai_create_user() {
fi fi
if [ "$rkey" = "syui" ];then if [ "$rkey" = "syui" ];then
cname=chinese cname=chinese
did=$did_syui
handle=syui.ai
cid=bafkreidlealfybajqzwv5eoz4jshnsijc2vnktlhpw4ph47krwj6aigqby cid=bafkreidlealfybajqzwv5eoz4jshnsijc2vnktlhpw4ph47krwj6aigqby
gender=male gender=male
fi fi
@ -271,6 +272,8 @@ function ai_create_user() {
\"rkey\": \"$rkey\", \"rkey\": \"$rkey\",
\"record\": { \"record\": {
\"version\": 2, \"version\": 2,
\"did\": \"$did\",
\"handle\": \"$handle\",
\"player\": { \"player\": {
\"did\": \"$did\", \"did\": \"$did\",
\"handle\": \"$handle\", \"handle\": \"$handle\",
@ -296,29 +299,54 @@ if echo $json|jq . ;then
fi fi
fi fi
col=ai.syui.game #col=ai.syui.game
rkey=self #rkey=self
at_uri=at://$did_yui/ai.syui.game.user/ai #at_uri=at://$did_yui/ai.syui.game.user/ai
#
json=" #json="
{ #{
\"repo\": \"$handle_yui\", # \"repo\": \"$handle_yui\",
\"did\": \"$did_yui\", # \"did\": \"$did_yui\",
\"collection\": \"$col\", # \"collection\": \"$col\",
\"rkey\": \"$rkey\", # \"rkey\": \"$rkey\",
\"record\": { # \"record\": {
\"account\": \"$at_uri\", # \"account\": \"$at_uri\",
\"username\": \"ai\", # \"username\": \"ai\",
\"createdAt\": \"$created\" # \"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 get_game_user() {
echo y rkey=$did.$pds
read y pds=bsky.social
if [ "y" = "$y" ];then if [ "$1" = "syui" ] || [ "$1" = "ai" ];then
curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url rkey=$1
fi 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
}

View File

@ -1,4 +1,5 @@
function at-env() { function at-env() {
pds=bsky.social
host=https://bsky.social host=https://bsky.social
handle_syui=syui.ai handle_syui=syui.ai
handle_yui=yui.syui.ai handle_yui=yui.syui.ai