fix scpt
This commit is contained in:
		
							
								
								
									
										18
									
								
								scpt/at.zsh
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								scpt/at.zsh
									
									
									
									
									
								
							| @@ -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 | 		create_game_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[@]}" | ||||||
|   | |||||||
| @@ -189,60 +189,89 @@ 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 . | ||||||
|  | } | ||||||
|  |  | ||||||
| 	col=ai.syui.game.user | delete_game_user() { | ||||||
| 	rkey=ai | 	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 | 	did=$did_yui | ||||||
| 	handle=$handle_yui | 	handle=$handle_yui | ||||||
|  | 	pds=bsky.social | ||||||
|  | 	version=2 | ||||||
| 	#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 | ||||||
| 		imguri=https://cdn.bsky.app/img/feed_thumbnail/plain/$did_yui/${cid}@jpeg | 		cid=bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy | ||||||
| 		echo $imguri | 		gender=none | ||||||
| 		echo $i $character $cname | 	fi | ||||||
| 		season=1 | 	if [ "$rkey" = "syui" ];then | ||||||
| 		group=test | 		cname=chinese | ||||||
| 		lv=1 | 		did=$did_syui | ||||||
| 		hp=100 | 		handle=syui.ai | ||||||
| 		exp=0 | 		cid=bafkreidlealfybajqzwv5eoz4jshnsijc2vnktlhpw4ph47krwj6aigqby | ||||||
| 		rank=0 | 		gender=male | ||||||
| 		mode=0 | 	fi | ||||||
| 		attack=0 | 	imguri=https://cdn.bsky.app/img/feed_thumbnail/plain/$did_yui/${cid}@jpeg | ||||||
| 		attack_post=0 | 	season=1 | ||||||
| 		critical=0 | 	group=test | ||||||
| 		critical_d=0 | 	lv=1 | ||||||
|  | 	hp=1 | ||||||
|  | 	exp=0 | ||||||
|  | 	rank=0 | ||||||
|  | 	mode=0 | ||||||
|  | 	attack=0 | ||||||
|  | 	attack_post=0 | ||||||
|  | 	critical=0 | ||||||
|  | 	critical_d=0 | ||||||
|  |  | ||||||
| 		case $cname in | 	case $cname in | ||||||
| 			ai) | 		ai) | ||||||
| 				group=origin | 			group=origin | ||||||
| 				season=0 | 			season=0 | ||||||
| 				mode=2 | 			mode=2 | ||||||
| 				;; | 			;; | ||||||
| 			manny|quinn) | 		manny|quinn) | ||||||
| 				group=test | 			group=test | ||||||
| 				;; | 			;; | ||||||
| 			*) | 		*) | ||||||
| 				group=fantasy | 			group=fantasy | ||||||
| 				;; | 			;; | ||||||
| 		esac | 	esac | ||||||
|  | 	json="\"$cname\": { \"group\": \"$group\", \"season\": $season, \"lv\": $lv, \"exp\": $exp, \"hp\": $hp, \"rank\": $rank, \"mode\": $mode, \"attack\": $attack, \"critical\": $critical, \"critical_d\": $critical_d }" | ||||||
|  | 	#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 +283,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,40 +292,52 @@ function ai_create_user() { | |||||||
| } | } | ||||||
| }" | }" | ||||||
|  |  | ||||||
|  | json_item=" | ||||||
|  | \"coin\": { \"id\": 0, \"count\": 0 }, | ||||||
|  | \"card\": { \"id\": 0, \"count\": 0, \"cp\": 0, \"rare\": 0 }, | ||||||
|  | \"weapon\": { \"id\": 0, \"count\": 0, \"attack\": 0, \"type\": 0, \"tp\": 0 } | ||||||
|  | " | ||||||
|  |  | ||||||
| if echo $json|jq . ;then | 	json=" | ||||||
| 	echo $token_yui | 	{ | ||||||
| 	echo y | 		\"repo\": \"$handle_yui\", | ||||||
| 	read y | 		\"did\": \"$did_yui\", | ||||||
| 	if [ "y" = "$y" ];then | 		\"collection\": \"$col\", | ||||||
| 		curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token_yui" -d $json $url | 		\"rkey\": \"$rkey\", | ||||||
| 	fi | 		\"record\": { | ||||||
| fi | 			\"version\": $version, | ||||||
|  | 			\"did\": \"$did\", | ||||||
| col=ai.syui.game | 			\"handle\": \"$handle\", | ||||||
| rkey=self | 			\"plc\": \"$plc\", | ||||||
| at_uri=at://$did_yui/ai.syui.game.user/ai | 			\"pds\": \"$pds\", | ||||||
|  | 			\"player\": { | ||||||
| json=" | 				\"limit\": false, | ||||||
| { | 				\"login\": false, | ||||||
| 	\"repo\": \"$handle_yui\", | 				\"aiten\": 0, | ||||||
| 	\"did\": \"$did_yui\", | 				\"gender\": \"$gender\" | ||||||
| 	\"collection\": \"$col\", | 			}, | ||||||
| 	\"rkey\": \"$rkey\", | 			\"character\": { | ||||||
| 	\"record\": { | 				$json | ||||||
| 	\"account\": \"$at_uri\", | 			}, | ||||||
| 	\"username\": \"ai\", | 			\"item\": { | ||||||
| 	\"createdAt\": \"$created\" | 				$json_item | ||||||
| } | 			}, | ||||||
|  | 			\"createdAt\": \"${created}\", | ||||||
|  | 			\"updatedAt\": \"${created}\" | ||||||
|  | 	} | ||||||
| }" | }" | ||||||
|  |  | ||||||
| if echo $json|jq . ;then | 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 | 		t=`curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url` | ||||||
|  | 		echo $t|jq . | ||||||
|  | 		f=~/ai/ue/json/v${version}_${rkey}.json | ||||||
|  | 		if [ -f $f ];then | ||||||
|  | 			get_game_user $rkey >! $f | ||||||
|  | 		fi | ||||||
| 	fi | 	fi | ||||||
| fi | fi | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,6 @@ | |||||||
| function at-env() { | function at-env() { | ||||||
|  | 	pds=bsky.social | ||||||
|  | 	plc=plc.directory | ||||||
| 	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 | ||||||
| @@ -39,18 +41,17 @@ function at-version-env() { | |||||||
| 			;; | 			;; | ||||||
| 		*) | 		*) | ||||||
| 			tag=pds | 			tag=pds | ||||||
| 			list=( bsky.social syu.is boobee.blue socl.is ) | 			list=( bsky.social syu.is socl.is ) | ||||||
| 			;; | 			;; | ||||||
| 	esac | 	esac | ||||||
| 	title="atproto $tag version" | 	title="atproto $tag version" | ||||||
| 	latest=https://raw.githubusercontent.com/bluesky-social/atproto/refs/heads/main/packages/$tag/package.json | 	latest=https://raw.githubusercontent.com/bluesky-social/atproto/refs/heads/main/packages/$tag/package.json | ||||||
|  | 	latest=`curl -sL $latest |jq -r .version` | ||||||
| 	# bgs=( bsky.network bgs.syu.is ) | 	# bgs=( bsky.network bgs.syu.is ) | ||||||
| 	# plc=( plc.directory plc.syu.is ) | 	# plc=( plc.directory plc.syu.is ) | ||||||
| } | } | ||||||
|  |  | ||||||
| function at-version-json() { | function at-version-json() { | ||||||
| 	latest=`curl -sL $latest |jq -r .version` |  | ||||||
| 	echo "[{\"title\":\"$title\",\"latest\":\"$latest\"},[" | 	echo "[{\"title\":\"$title\",\"latest\":\"$latest\"},[" | ||||||
| 	e=${list[@]: -1} | 	e=${list[@]: -1} | ||||||
| 	for i in $list; do | 	for i in $list; do | ||||||
| @@ -64,8 +65,8 @@ function at-version-json() { | |||||||
| } | } | ||||||
|  |  | ||||||
| function at-version() { | function at-version() { | ||||||
| 	at-version-env $1 | 	at-version-env | ||||||
| 	at-version-json |jq . | 	at-version-json|jq . | ||||||
| } | } | ||||||
|  |  | ||||||
| function at-uri() { | function at-uri() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user