ai/at
ai/at
1
0
This commit is contained in:
syui 2025-03-19 08:23:32 +09:00
parent c3d75140d8
commit b408c47149
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
3 changed files with 134 additions and 75 deletions

View File

@ -38,16 +38,24 @@ case $1 in
at-profile at-profile
;; ;;
download-character-icon) download-character-icon)
source $d/ai/syui/game/character.zsh source $d/src/ai/syui/game/character.zsh
download_character_icon download_character_icon
;; ;;
create-game-character) create-game-character)
source $d/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/ai/syui/game/character.zsh source $d/src/ai/syui/game/character.zsh
ai_create_user 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[@]}"

View File

@ -190,27 +190,36 @@ json="{
} }
function ai_create_user() { function ai_create_user() {
col=ai.syui.game
col=ai.syui.game.user rkey=$1
rkey=ai
did=$did_yui did=$did_yui
handle=$handle_yui handle=$handle_yui
pds=bsky.social
#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://$host/xrpc/$req url=https://$pds/xrpc/$req
for ((i=1; i<=${#character}; i++)); do cname=dragon
cid=bafkreia3huw2gdenqatoobx3hcft74chced46bw4znfgepo5aenegobkri
cname=${character[$i]} if [ "$rkey" = "ai" ];then
cid=${img[$i]} cname=$rkey
cid=bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy
gender=none
fi
if [ "$rkey" = "syui" ];then
cname=chinese
did=$did_syui
handle=syui.ai
cid=bafkreidlealfybajqzwv5eoz4jshnsijc2vnktlhpw4ph47krwj6aigqby
gender=male
fi
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
echo $imguri
echo $i $character $cname
season=1 season=1
group=test group=test
lv=1 lv=1
hp=100 hp=1
exp=0 exp=0
rank=0 rank=0
mode=0 mode=0
@ -232,17 +241,9 @@ function ai_create_user() {
group=fantasy group=fantasy
;; ;;
esac esac
json="\"$cname\": { \"group\": \"$group\", \"season\": $season, \"img\": \"$imguri\", \"lv\": $lv, \"exp\": $exp, \"hp\": $hp, \"rank\": $rank, \"mode\": $mode, \"attack\": $attack, \"attack_post\": $attack_post, \"critical\": $critical, \"critical_d\": $critical_d }"
jc="\"$cname\": { \"group\": \"$group\", \"season\": $season, \"img\": \"$imguri\", \"lv\": $lv, \"exp\": $exp, \"hp\": $hp, \"rank\": $rank, \"mode\": $mode, \"attack\": $attack, \"attack_post\": $attack_post, \"critical\": $critical, \"critical_d\": $critical_d }" v1_json="
if [ $#character -ne $i ];then
jc=${jc},
fi
json=${json}${jc}
done
json="
{ {
\"repo\": \"$handle_yui\", \"repo\": \"$handle_yui\",
\"did\": \"$did_yui\", \"did\": \"$did_yui\",
@ -254,7 +255,7 @@ function ai_create_user() {
\"login\": false, \"login\": false,
\"handle\": \"$handle\", \"handle\": \"$handle\",
\"aiten\": 10, \"aiten\": 10,
\"gender\": \"famale\", \"gender\": \"$gender\",
\"character\": { \"character\": {
$json $json
}, },
@ -263,30 +264,30 @@ function ai_create_user() {
} }
}" }"
json="
if echo $json|jq . ;then {
echo $token_yui
echo y
read y
if [ "y" = "$y" ];then
curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token_yui" -d $json $url
fi
fi
col=ai.syui.game
rkey=self
at_uri=at://$did_yui/ai.syui.game.user/ai
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\", \"version\": 2,
\"username\": \"ai\", \"did\": \"$did\",
\"createdAt\": \"$created\" \"handle\": \"$handle\",
\"player\": {
\"did\": \"$did\",
\"handle\": \"$handle\",
\"pds\": \"$pds\",
\"limit\": false,
\"login\": false,
\"aiten\": 0,
\"gender\": \"$gender\"
},
\"character\": {
$json
},
\"createdAt\": \"${created}\",
\"updatedAt\": \"${created}\"
} }
}" }"
@ -294,9 +295,58 @@ if echo $json|jq . ;then
echo y echo y
read y read y
if [ "y" = "$y" ];then if [ "y" = "$y" ];then
curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token_yui" -d $json $url curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url
fi 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
}

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