v0.1
This commit is contained in:
		
							
								
								
									
										3
									
								
								scpt/entrypoint.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								scpt/entrypoint.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
exec "$@"
 | 
			
		||||
							
								
								
									
										34
									
								
								scpt/env
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								scpt/env
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
cfg=~/.config/ai/test.json
 | 
			
		||||
 | 
			
		||||
if [ ! -f $cfg ] || ! cat $cfg|jq . || [ "`cat $cfg|jq .host`" = "null" ] || [ -z "`cat $cfg`" ];then
 | 
			
		||||
	mkdir -p ~/.config/ai
 | 
			
		||||
	echo server:
 | 
			
		||||
	read host
 | 
			
		||||
 | 
			
		||||
	echo password:
 | 
			
		||||
	read pass
 | 
			
		||||
 | 
			
		||||
	echo handle:
 | 
			
		||||
	read handle
 | 
			
		||||
 | 
			
		||||
	echo "{ \"host\":\"$host\", \"password\":\"$pass\", \"handle\":\"$handle\" }" >> $cfg
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
host=`cat $cfg|jq -r .host`
 | 
			
		||||
handle=`cat $cfg|jq -r .handle`
 | 
			
		||||
pass=`cat $cfg|jq -r .password`
 | 
			
		||||
date=`date --iso-8601=seconds`
 | 
			
		||||
 | 
			
		||||
if [ ! -f $cfg.t ];then
 | 
			
		||||
	$d/token.zsh
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -f $cfg.t ];then
 | 
			
		||||
	token=`cat $cfg.t|jq -r .accessJwt`
 | 
			
		||||
	refresh=`cat $cfg.t|jq -r .refreshJwt`
 | 
			
		||||
	did=`cat $cfg.t|jq -r .did`
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ ! -d $d/json ];then
 | 
			
		||||
	mkdir -p $d/json
 | 
			
		||||
fi
 | 
			
		||||
							
								
								
									
										37
									
								
								scpt/notify.zsh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								scpt/notify.zsh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
function notify() {
 | 
			
		||||
	url=https://$host/xrpc/app.bsky.notification.listNotifications
 | 
			
		||||
	f=$d/json/notify.json
 | 
			
		||||
	if [ ! -f $f ];then
 | 
			
		||||
		curl -sL "Content-Type: application/json" -H "Authorization: Bearer $token" "$url?limit=100" >! $f
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	for ((i=0;i<=99;i++))
 | 
			
		||||
	do
 | 
			
		||||
		echo "[$i]---"
 | 
			
		||||
		cid=`cat $f|jq -r ".|.[].[$i]?|.cid?"`
 | 
			
		||||
		uri=`cat $f|jq -r ".|.[].[$i]?|.uri?"`
 | 
			
		||||
		echo cid: $cid
 | 
			
		||||
		echo uri: $uri
 | 
			
		||||
		cid_r=`cat $f|jq -r ".[]|.[$i]?|.record.reply.root.cid?"`
 | 
			
		||||
 | 
			
		||||
		if [ "$cid_r" = "null" ];then
 | 
			
		||||
			continue
 | 
			
		||||
		fi
 | 
			
		||||
		uri_r=`cat $f|jq -r ".[]|.[$i]?|.record.reply.root.uri?"`
 | 
			
		||||
		cid_p=`cat $f|jq -r ".[]|.[$i]?|.record.reply.parent.cid?"`
 | 
			
		||||
		uri_p=`cat $f|jq -r ".[]|.[$i]?|.record.reply.parent.uri?"`
 | 
			
		||||
		did_p=`echo $uri_p|cut -d / -f 3`
 | 
			
		||||
		if [ "$did_p" != "did:plc:uqzpqmrjnptsxezjx4xuh2mn" ];then
 | 
			
		||||
			continue
 | 
			
		||||
		fi
 | 
			
		||||
		echo cid_root: $cid_r
 | 
			
		||||
		echo uri_root: $uri_r
 | 
			
		||||
		echo cid_parent: $cid_p
 | 
			
		||||
		echo uri_parent: $uri_p
 | 
			
		||||
		echo ---
 | 
			
		||||
		echo uri: $uri|sed "s#at://#https://bsky.app/profile/#g"|sed 's/app.bsky.feed.post/post/g'
 | 
			
		||||
		echo uri_root: $uri_r|sed "s#at://#https://bsky.app/profile/#g"|sed 's/app.bsky.feed.post/post/g'
 | 
			
		||||
		echo uri_parent: $uri_p|sed "s#at://#https://bsky.app/profile/#g"|sed 's/app.bsky.feed.post/post/g'
 | 
			
		||||
		echo ---
 | 
			
		||||
	done
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								scpt/refresh.zsh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										11
									
								
								scpt/refresh.zsh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
function refresh(){
 | 
			
		||||
	token=`cat $cfg.t|jq -r .accessJwt`
 | 
			
		||||
	refresh=`cat $cfg.t|jq -r .refreshJwt`
 | 
			
		||||
	if [ ! -f $cfg ];then
 | 
			
		||||
		token
 | 
			
		||||
	fi
 | 
			
		||||
	url=https://$host/xrpc/com.atproto.server.refreshSession
 | 
			
		||||
	j=`curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $refresh" $url`
 | 
			
		||||
	echo $j
 | 
			
		||||
	echo $j >! $cfg.t
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										40
									
								
								scpt/reply.zsh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										40
									
								
								scpt/reply.zsh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
function reply() {
 | 
			
		||||
 | 
			
		||||
	#uri: https://bsky.app/profile/did:plc:4hqjfn7m6n5hno3doamuhgef/post/3kkumyv72w22o
 | 
			
		||||
	#uri_root: https://bsky.app/profile/did:plc:uqzpqmrjnptsxezjx4xuh2mn/post/3kkumysfipk2p
 | 
			
		||||
	#uri_parent: https://bsky.app/profile/did:plc:uqzpqmrjnptsxezjx4xuh2mn/post/3kkumysfipk2p
 | 
			
		||||
 | 
			
		||||
	cid=bafyreiaxz6hbqgylsxglqita73c5gzxzoatupgitd35rwjpd6dzpa4ctwi
 | 
			
		||||
	uri=at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3kkumyv72w22o
 | 
			
		||||
	cid_root=bafyreiacxuk4ypaxbg7qxnmrvpnaej5o7azewqioelfgbuikp77jevy6hq
 | 
			
		||||
	uri_root=at://did:plc:uqzpqmrjnptsxezjx4xuh2mn/app.bsky.feed.post/3kkumysfipk2p
 | 
			
		||||
	cid_parent=bafyreiacxuk4ypaxbg7qxnmrvpnaej5o7azewqioelfgbuikp77jevy6hq
 | 
			
		||||
	uri_parent=at://did:plc:uqzpqmrjnptsxezjx4xuh2mn/app.bsky.feed.post/3kkumysfipk2p
 | 
			
		||||
 | 
			
		||||
	url="https://$host/xrpc/com.atproto.repo.createRecord"
 | 
			
		||||
	col="app.bsky.feed.post"
 | 
			
		||||
 | 
			
		||||
json="{
 | 
			
		||||
    \"repo\": \"$handle\",
 | 
			
		||||
    \"did\": \"$did\",
 | 
			
		||||
    \"collection\": \"$col\",
 | 
			
		||||
    \"record\": {
 | 
			
		||||
        \"text\": \"$text\",
 | 
			
		||||
        \"createdAt\": \"$date\",
 | 
			
		||||
        \"reply\": {
 | 
			
		||||
            \"root\": {
 | 
			
		||||
                \"cid\": \"$cid_root\",
 | 
			
		||||
                \"uri\": \"$uri_root\"
 | 
			
		||||
            },
 | 
			
		||||
            \"parent\": {
 | 
			
		||||
                \"cid\": \"$cid\",
 | 
			
		||||
                \"uri\": \"$uri\"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}"
 | 
			
		||||
 | 
			
		||||
	echo $json|jq .
 | 
			
		||||
	url=https://$host/xrpc/com.atproto.repo.createRecord
 | 
			
		||||
	curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d "$json" $url
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										6
									
								
								scpt/token.zsh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										6
									
								
								scpt/token.zsh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
function token() {
 | 
			
		||||
	url=https://$host/xrpc/com.atproto.server.createSession
 | 
			
		||||
	j=`curl -sL -X POST -H "Content-Type: application/json" -d "{\"identifier\":\"$handle\",\"password\":\"$pass\"}" $url`
 | 
			
		||||
	echo $j
 | 
			
		||||
 echo $j >! $cfg.t
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user