fix scpt
This commit is contained in:
parent
036489dc20
commit
ff52c8444b
@ -3,6 +3,7 @@
|
||||
# raid-boss-admin
|
||||
cfg=$HOME/.config/ai/scpt/card_config.json
|
||||
cfg_ai=$HOME/.config/ai/scpt/card_config_ai.json
|
||||
host_bsky=`cat ~/.config/ai/token.toml|head -n 1 |cut -d '"' -f 2`
|
||||
# {
|
||||
# "raid_admin":"yui.bsky.social",
|
||||
# "raid_time": "",
|
||||
@ -666,7 +667,12 @@ function battle_server(){
|
||||
f_server_at=$HOME/.config/ai/txt/card_server_at.txt
|
||||
f_server_start_time=$HOME/.config/ai/txt/card_server_start_time.txt
|
||||
|
||||
at_endpoint=`curl -sL https://plc.directory/$did|jq -r ".service.[].serviceEndpoint"|cut -d . -f 1-2|cut -d / -f 3`
|
||||
if [ "$host_bsky" = "bsky.social" ];then
|
||||
at_endpoint=`curl -sL https://plc.directory/$did|jq -r ".service.[].serviceEndpoint"|cut -d . -f 1-2|cut -d / -f 3`
|
||||
else
|
||||
at_endpoint=$host_bsky
|
||||
fi
|
||||
|
||||
at_endpoint_f=$HOME/.config/ai/txt/at_endpoint_${at_endpoint}_.txt
|
||||
touch $at_endpoint_f
|
||||
a_team=$at_endpoint
|
||||
|
@ -30,8 +30,7 @@ host_card_json=`curl -sL $host_card`
|
||||
n_cid=$HOME/.config/ai/txt/tmp_notify_cid.txt
|
||||
f_cfg=$HOME/.config/ai/txt/tmp_ten_config.txt
|
||||
|
||||
host=`cat ~/.config/ai/token.toml|head -n 1 |cut -d '"' -f 2`
|
||||
|
||||
host_bsky=`cat ~/.config/ai/token.toml|head -n 1 |cut -d '"' -f 2`
|
||||
|
||||
function moon_check(){
|
||||
moon_now=`date +"%Y%m%d"`
|
||||
@ -826,7 +825,7 @@ function card_post() {
|
||||
link="https://card.syui.ai/${username}"
|
||||
text=`echo "$title +${cten}\n$body\nten : $ten_su\n$ten_kai : $old_ten_char ---> $ten_char $ten_yak_ok"`
|
||||
|
||||
if [ "$host" = "bsky.social" ];then
|
||||
if [ "$host_bsky" = "bsky.social" ];then
|
||||
tmp_atr=`ai reply-og "$text" --cid $cid --uri $uri --img $img --title "$title" --description "$desc" --link $link`
|
||||
else
|
||||
tmp_atr=`ai reply "$text" --cid $cid --uri $uri`
|
||||
|
@ -1,21 +0,0 @@
|
||||
#!/bin/zsh
|
||||
d=${0:a:h:h}
|
||||
url="search.bsky.social/search/posts?q="
|
||||
q=`echo $*|tr ' ' '+'`
|
||||
url="${url}${q}"
|
||||
|
||||
t=`curl -sL "$url"`
|
||||
echo $t
|
||||
n=`echo $t|jq "length"`
|
||||
n=`expr $n - 1`
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
did=`echo $t|jq -r ".[$i].user.did"`
|
||||
text=`echo $t|jq -r ".[$i].post.text"`
|
||||
tid=`echo $t|jq -r ".[$i].tid"`
|
||||
if [ "$text" != "null" ];then
|
||||
echo $did
|
||||
echo $text
|
||||
echo https://$tid
|
||||
fi
|
||||
done
|
@ -1,24 +0,0 @@
|
||||
#!/bin/zsh
|
||||
d=${0:a:h}
|
||||
dd=${0:a:h:h}/json
|
||||
#https://github.com/bluesky-social/atproto/issues/597
|
||||
host=bsky.social
|
||||
base=https://$host/xrpc
|
||||
handle=`cat ~/.config/atr/token.json| jq -r .handle`
|
||||
token=`cat ~/.config/atr/token.json| jq -r .accessJwt`
|
||||
if [ -n "$1" ];then
|
||||
url=$base/$1
|
||||
else
|
||||
url="$base/app.bsky.actor.getProfile?actor=$handle"
|
||||
fi
|
||||
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url | jq . >! $dd/profile.json
|
||||
cat $dd/profile.json
|
||||
|
||||
url=$base/app.bsky.feed.getTimeline
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url | jq . >! $dd/timeline.json
|
||||
cat $dd/timeline.json
|
||||
|
||||
url=$base/app.bsky.notification.listNotifications
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url | jq . >! $dd/notify.json
|
||||
cat $dd/notify.json|jq .
|
@ -1,39 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
host_at=bsky.social
|
||||
url_at=https://$host_at/xrpc/com.atproto.repo.listRecords
|
||||
scpt=$HOME/.config/ai/scpt/api_card.zsh
|
||||
|
||||
handle=skychan.social
|
||||
did=did:plc:7hgow77uky7lgbinwyvbzhar
|
||||
f=$HOME/.config/ai/card_bot.txt
|
||||
touch $f
|
||||
|
||||
n=5
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
echo $i
|
||||
cid=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post" |jq -r ".[]|.[$i]?|.cid"`
|
||||
uri=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post" |jq -r ".[]|.[$i]?|.uri"`
|
||||
t=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post" |jq -r ".[]|.[$i]?|.value.text"`
|
||||
echo $t $cid $uri
|
||||
if [ "@yui.syui.ai /card" = "$t" ];then
|
||||
if [ "$cid" = "`cat $f`" ];then
|
||||
exit
|
||||
fi
|
||||
card=`$scpt $handle $did`
|
||||
link="https://card.syui.ai/skychan"
|
||||
~/.cargo/bin/atr r "$card" -c $cid -u "$uri" -l "$link"
|
||||
echo $cid >! $f
|
||||
fi
|
||||
if [ "@yui.syui.ai /card -b" = "$t" ];then
|
||||
if [ "$cid" = "`cat $f`" ];then
|
||||
exit
|
||||
fi
|
||||
card=`$scpt $handle $did -b`
|
||||
link="https://card.syui.ai/skychan"
|
||||
~/.cargo/bin/atr r "\n$card" -c $cid -u "$uri" -l "$link"
|
||||
echo $cid >! $f
|
||||
fi
|
||||
done
|
||||
exit
|
@ -1,60 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
d=$HOME/.config/ai/txt
|
||||
mkdir -p $d
|
||||
f=$d/kawaii.txt
|
||||
|
||||
function test_post() {
|
||||
host_at=bsky.social
|
||||
url_at=https://$host_at/xrpc/com.atproto.repo.listRecords
|
||||
handle=lilly-niyu.bsky.social
|
||||
n=10
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
echo $i
|
||||
cid=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post" |jq -r ".[]|.[$i]?|.cid"`
|
||||
uri=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post" |jq -r ".[]|.[$i]?|.uri"`
|
||||
t=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post" |jq -r ".[]|.[$i]?|.value.text"`
|
||||
echo $t $cid $uri
|
||||
if [ "かわいいにゃ〜!!" = "$t" ];then
|
||||
#atr r "楽しそう!アイもまぜてよ" -c $cid -u "$uri"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#uri=at://$did/$tid
|
||||
#{
|
||||
# "tid": "app.bsky.feed.post/3judrtmxuin2b",
|
||||
# "cid": "bafyreibebbn7og5dgvvegcjlh357pnrpuvvinbjeaqbfvqb4jsrpbsw3di",
|
||||
# "user": {
|
||||
# "did": "did:plc:hodycxjeqfxtest2ilj47j7g",
|
||||
# "handle": "lilly-niyu.bsky.social"
|
||||
# },
|
||||
# "post": {
|
||||
# "createdAt": 1682587582509000000,
|
||||
# "text": "かわいいにゃ〜!!",
|
||||
# "user": "lilly-niyu.bsky.social"
|
||||
# }
|
||||
#}
|
||||
|
||||
url="search.bsky.social/search/posts?q=かわいいにゃ〜!!"
|
||||
q=`echo $*|tr ' ' '+'`
|
||||
url="${url}${q}"
|
||||
|
||||
t=`curl -sL "$url"`
|
||||
cid=`echo $t|jq -r ".[1].cid"`
|
||||
did=`echo $t|jq -r ".[1].did"`
|
||||
tid=`echo $t|jq -r ".[1].tid"`
|
||||
uri="at://$did/$tid"
|
||||
text=`echo $t|jq -r ".[1].post.text"`
|
||||
|
||||
touch $f
|
||||
|
||||
echo $text
|
||||
if [ "かわいいにゃ〜!!" = "$text" ] && [ "`cat $f`" != "$cid" ];then
|
||||
echo ok
|
||||
atr r "楽しそう!アイもまぜてよ" -c $cid -u "$uri"
|
||||
echo $cid >! $f
|
||||
else
|
||||
echo no
|
||||
fi
|
@ -1,79 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
url_plc="https://plc.directory/export"
|
||||
host_at=bsky.social
|
||||
url=https://plc.directory
|
||||
url_at=https://$host_at/xrpc/com.atproto.repo.listRecords
|
||||
dir=$HOME/.config/atr/txt
|
||||
file=$dir/bot_list.txt
|
||||
unset timed
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $1|grep "." >/dev/null 2>&1;then
|
||||
echo "ex : user syui.bsky.social"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -d $dir ];then
|
||||
mkdir -p $dir
|
||||
fi
|
||||
|
||||
if [ ! -f $file ];then
|
||||
touch $file
|
||||
fi
|
||||
|
||||
function mfile() {
|
||||
t=`cat $file|sort|uniq`
|
||||
if [ -n "$t" ];then
|
||||
echo "$t" >! ${file}.back
|
||||
mv ${file}.back $file
|
||||
fi
|
||||
}
|
||||
|
||||
function plc(){
|
||||
if cat $file|grep "$1" >/dev/null 2>&1;then
|
||||
cat $file|grep "$1"
|
||||
exit
|
||||
fi
|
||||
json_tmp=`curl -sL "${url_plc}?after=${timed}"|jq .`
|
||||
json=`echo $json_tmp|jq "select(.operation.handle == \"$1\")"`
|
||||
if [ -z "$json" ];then
|
||||
check=`echo $json_tmp|jq -r ".operation.alsoKnownAs"|head -n 1`
|
||||
if [ "null" != "$check" ];then
|
||||
json=`echo $json_tmp|jq "select(.operation.alsoKnownAs|.[] == \"at://$1\")"` >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
if [ -n "$json" ];then
|
||||
created_at=`echo $json|jq -r .createdAt |tail -n 1`
|
||||
fi
|
||||
if [ -n "$created_at" ];then
|
||||
echo "$created_at : $1"
|
||||
echo "$created_at : $1" >> $file
|
||||
mfile
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" = "-l" ];then
|
||||
mfile
|
||||
cat $file
|
||||
exit
|
||||
fi
|
||||
|
||||
for ((i=0;i<=20;i++))
|
||||
do
|
||||
if [ $i -eq 0 ];then
|
||||
timed="1970-01-01"
|
||||
fi
|
||||
plc $1
|
||||
timed=`echo $json_tmp|jq -r .createdAt|tail -n 1`
|
||||
done
|
@ -1,29 +0,0 @@
|
||||
#!/bin/zsh
|
||||
d=${0:a:h}
|
||||
dd=${0:a:h:h}/json
|
||||
#https://github.com/bluesky-social/atproto/issues/597
|
||||
host=`cat ~/.config/atr/config.json|jq -r .host`
|
||||
base=https://$host/xrpc
|
||||
handle=`cat ~/.config/atr/config.json|jq -r .user`
|
||||
pass=`cat ~/.config/atr/config.json|jq -r .pass`
|
||||
f=~/.config/atr/token.json
|
||||
|
||||
curl -X POST -H "Content-Type: application/json" -d "{\"identifier\":\"$handle\",\"password\":\"$pass\"}" https://$host/xrpc/com.atproto.server.createSession | jq . >! $f
|
||||
cat $f
|
||||
|
||||
if [ "$1" = "-a" ];then
|
||||
handle=`cat $f| jq -r .handle`
|
||||
token=`cat $f| jq -r .accessJwt`
|
||||
|
||||
url="$base/app.bsky.actor.getProfile?actor=$handle"
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url | jq . >! $dd/profile.json
|
||||
cat $dd/profile.json
|
||||
|
||||
url=$base/app.bsky.feed.getTimeline
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url | jq . >! $dd/timeline.json
|
||||
cat $dd/timeline.json
|
||||
|
||||
url=$base/app.bsky.notification.listNotifications
|
||||
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $token" $url | jq . >! $dd/notify.json
|
||||
cat $dd/notify.json|jq .
|
||||
fi
|
@ -4,18 +4,23 @@ dir=${0:a:h}
|
||||
mkdir -p $dir/png
|
||||
f=$dir/png/t.png
|
||||
f_sleep=$dir/png/sleep
|
||||
txt=~/.config/ai/txt
|
||||
|
||||
if [ ! -d $txt ];then
|
||||
mkdir -p $txt
|
||||
fi
|
||||
|
||||
cfg=$dir/stable_diffusion_prompt.j
|
||||
cfg_did=$dir/stable_diffusion_did.txt
|
||||
opt_af=$dir/stable_diffusion_a.txt
|
||||
opt_bf=$dir/stable_diffusion_b.txt
|
||||
opt_allf=$dir/stable_diffusion_all.txt
|
||||
cfg_did=$txt/stable_diffusion_did.txt
|
||||
opt_af=$txt/stable_diffusion_a.txt
|
||||
opt_bf=$txt/stable_diffusion_b.txt
|
||||
opt_allf=$txt/stable_diffusion_all.txt
|
||||
|
||||
if [ ! -f $cfg_did ];then
|
||||
touch $cfg_did
|
||||
fi
|
||||
|
||||
did=$1
|
||||
admin=did:plc:uqzpqmrjnptsxezjx4xuh2mn
|
||||
|
||||
if [ ! -f $cfg ];then
|
||||
echo no file $cfg
|
||||
@ -25,16 +30,6 @@ fi
|
||||
opt_a=`echo $@|cut -d ' ' -f 2`
|
||||
opt_b=`echo $@|cut -d ' ' -f 3`
|
||||
|
||||
#case "$opt_b" in
|
||||
# bluesky|sky|field|girl|anime|universe|earth|bird|miku|ai|yui|card|blue|cat)
|
||||
# ;;
|
||||
# *)
|
||||
# if [ -n "$opt_b" ] && [ "$did" != "$admin" ];then
|
||||
# opt_b=nyancat
|
||||
# fi
|
||||
# ;;
|
||||
#esac
|
||||
|
||||
echo $opt_a >! $opt_af
|
||||
echo $opt_b >! $opt_bf
|
||||
echo $@ >! $opt_allf
|
||||
@ -106,3 +101,4 @@ else
|
||||
echo "\n$did" >> $cfg_did
|
||||
run
|
||||
fi
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/zsh
|
||||
|
||||
dir=${0:a:h}
|
||||
f=$HOME/.config/ai/scpt/png/t.png
|
||||
f=$HOME/.config/ai/png/t.png
|
||||
|
||||
cid=$1
|
||||
uri=$2
|
||||
|
@ -1,8 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
txt=_atproto.$1
|
||||
did=$2
|
||||
curl -sL plc.directory/$did/log |jq ".[]|.alsoKnownAs|.[]?" | grep -n .| head -n 4
|
||||
|
||||
dig -t TXT $txt|grep "did=did:plc:"|head -n 1
|
||||
#dig syui.ai +short
|
@ -1,145 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
url_plc="https://plc.directory/export"
|
||||
host_at=bsky.social
|
||||
url=https://plc.directory
|
||||
url_at=https://$host_at/xrpc/com.atproto.repo.listRecords
|
||||
dir=$HOME/.config/atr/txt
|
||||
file=$dir/user_list.txt
|
||||
|
||||
opt=`echo $4|tr -d "'"`
|
||||
dir_git_card_page=$HOME/git/card.syui.ai
|
||||
|
||||
if [ ! -d $dir_git_card_page ];then
|
||||
mkdir -p $HOME/git
|
||||
cd $HOME/git
|
||||
git clone https://github.com/syui/card.syui.ai
|
||||
else
|
||||
cd $dir_git_card_page
|
||||
t=`git pull`
|
||||
fi
|
||||
|
||||
file_fanart=$dir_git_card_page/public/json/fanart.json
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
created_at=`date --iso-8601=seconds`
|
||||
|
||||
#if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ];then
|
||||
# exit
|
||||
#fi
|
||||
|
||||
function fan_art_search() {
|
||||
k="aifanart"
|
||||
url="search.bsky.social/search/posts?q="
|
||||
t=`curl -sL "${url}${k}"|jq ".[]|select(.post.text == \"$k\")"`
|
||||
#n=`curl -sL "${url}${k}"|jq length`
|
||||
n=$((n - 1))
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
did=`curl -sL "${url}${k}"|jq -r ".[$i]|.user.did"`
|
||||
handle=`curl -sL https://plc.directory/$did|jq -r ".alsoKnownAs|.[]"|cut -d / -f 3-`
|
||||
if [ -z "$handle" ];then
|
||||
continue
|
||||
fi
|
||||
tid=`curl -sL "${url}${k}"|jq -r ".[$i]|.tid"|cut -d / -f 2`
|
||||
http=https://staging.bsky.app/profile/$handle/post/$tid
|
||||
echo $http
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "-s" ];then
|
||||
fan_art_search
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $1|grep "." >/dev/null 2>&1;then
|
||||
echo "ex : user syui.bsky.social"
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $2|grep "did:plc:" >/dev/null 2>&1;then
|
||||
echo "ex : user did"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$3" = "-l" ];then
|
||||
curl -sL card.syui.ai/json/fanart.json|jq -r ".[]|.author, .link"
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $3|grep -e "bsky.app/profile/" -e "nostter.vercel.app" >/dev/null 2>&1;then
|
||||
echo "please url : bsky.app/profile/$1/post/xxx"
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $4|grep -e "https://av-cdn.bsky.app/img" -e "https://nostr.build/i/" >/dev/null 2>&1;then
|
||||
if [ "$opt" != "-d" ];then
|
||||
echo "please url : av-cdn.bsky.social/img"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
function fan_art(){
|
||||
add=$1
|
||||
did=$2
|
||||
if echo $3|grep "nostter.vercel.app" >/dev/null 2>&1;then
|
||||
link=`echo $3|cut -d / -f 1-4`
|
||||
else
|
||||
link=$3
|
||||
fi
|
||||
img=`echo $4|tr -d "'"`
|
||||
author=`echo $3|cut -d / -f 5`
|
||||
if [ -z "$author" ];then
|
||||
author="nostr"
|
||||
fi
|
||||
cd $dir_git_card_page
|
||||
check_null=`cat $file_fanart|jq ".[]|select(.img == \"$img\")"`
|
||||
if [ -n "$check_null" ];then
|
||||
echo registered
|
||||
exit
|
||||
fi
|
||||
echo `cat $file_fanart` "[{\"add\":\"$add\",\"link\":\"$link\",\"author\":\"$author\",\"img\":\"$img\",\"created_at\":\"$created_at\",\"did\":\"$did\"}]" | jq -s add >! $file_fanart.back
|
||||
if cat $file_fanart.back|jq . >/dev/null 2>&1;then
|
||||
mv $file_fanart.back $file_fanart
|
||||
git add $file_fanart
|
||||
git commit -m "add fanart"
|
||||
git push -u origin main -f
|
||||
echo add fanart, thx $1
|
||||
echo "author : $author"
|
||||
echo "it will take some time to deploy"
|
||||
fi
|
||||
}
|
||||
|
||||
function fan_art_delete(){
|
||||
add=$1
|
||||
did=$2
|
||||
link=$3
|
||||
cd $dir_git_card_page
|
||||
check_null=`cat $file_fanart|jq ".[]|select(.img == \"$img\")"`
|
||||
if [ -n "$check_null" ];then
|
||||
echo registered
|
||||
exit
|
||||
fi
|
||||
cat $file_fanart|jq ".[]|select(.link == \"$link\")|= .+{\"delete\":true,\"delete-did\":\"$did\"}"|jq -s >! $file_fanart.back
|
||||
if cat $file_fanart.back|jq . >/dev/null 2>&1;then
|
||||
mv $file_fanart.back $file_fanart
|
||||
git add $file_fanart
|
||||
git commit -m "delete fanart"
|
||||
git push -u origin main -f
|
||||
echo delete fanart, thx $1
|
||||
echo "delete-did : $did"
|
||||
echo "it will take some time to deploy"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$opt" = "-d" ];then
|
||||
fan_art_delete $1 $2 $3
|
||||
exit
|
||||
fi
|
||||
|
||||
fan_art $1 $2 $3 $4
|
||||
|
||||
exit
|
@ -1,14 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
admin_password=`cat $HOME/.config/ai/api_card.json|jq -r .pds_admin_password`
|
||||
if [ -n "$1" ];then
|
||||
host=$1
|
||||
else
|
||||
host=syu.is
|
||||
fi
|
||||
url=https://$host/xrpc/com.atproto.server.createInviteCode
|
||||
json="{\"useCount\":30}"
|
||||
echo $url
|
||||
echo $admin_password
|
||||
#curl -X POST -u admin:${admin_password} -H "Content-Type: application/json" -d "$json" -sL $url | jq -r .code
|
||||
curl -X POST -u admin:${admin_password} -H "Content-Type: application/json" -d "$json" -sL $url
|
@ -1,40 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
atr=$HOME/.cargo/bin/atr
|
||||
host=api.syui.ai
|
||||
data=`curl -sL "$host/users?itemsPerPage=3000"|jq ".|sort_by(.like)|reverse|.[]|select(.like_rank > 1)"`
|
||||
tmp=`echo $data|jq -s`
|
||||
n=`echo $tmp|jq "length"`
|
||||
ran=$(($RANDOM % n - 1))
|
||||
echo $ran
|
||||
|
||||
function did() {
|
||||
user=`echo $tmp|jq -r ".[$ran].username"`
|
||||
did=`echo $tmp|jq -r ".[$ran].did"`
|
||||
}
|
||||
|
||||
function tl(){
|
||||
did
|
||||
cid=`$atr f $did|jq -r ".records|.[0].cid"`
|
||||
uri=`$atr f $did|jq -r ".records|.[0].uri"`
|
||||
text=`$atr f $did|jq -r ".records|.[0].value.text"`
|
||||
echo $cid
|
||||
echo $uri
|
||||
echo $text
|
||||
find=`echo $text|grep "card.syui.ai"`
|
||||
find_t=`echo $text|grep "ten : "`
|
||||
if [ -n "$find" ] || [ -n "$find_t" ];then
|
||||
exit
|
||||
fi
|
||||
text=`$atr chat "$text" -c`
|
||||
echo $text
|
||||
}
|
||||
|
||||
function reply(){
|
||||
tl
|
||||
if [ -n "$text" ] && [ -n "$uri" ];then
|
||||
$atr r "$text" -u $uri -c $cid
|
||||
fi
|
||||
}
|
||||
|
||||
reply
|
@ -1,49 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
handle=$1
|
||||
did=$2
|
||||
text=$3
|
||||
|
||||
atr=$HOME/.cargo/bin/atr
|
||||
url_j=https://card.syui.ai/json/card.json
|
||||
handle=$1
|
||||
did=$2
|
||||
cid=$3
|
||||
uri=$4
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
url=https://api.syui.ai
|
||||
username=`echo $1|cut -d . -f 1`
|
||||
link=https://card.syui.ai/$username
|
||||
uid=`curl -sL "$url/users?itemsPerPage=2000"|jq ".[]|select(.username == \"$username\")"|jq -r .id`
|
||||
echo $uid
|
||||
|
||||
data=`curl -sL "$url/users/$uid"`
|
||||
like_old=`echo $data|jq -r .like`
|
||||
|
||||
nolike=$(($RANDOM % 30))
|
||||
like=$(($RANDOM % 10))
|
||||
like_at=`date --iso-8601=seconds`
|
||||
token=`cat $HOME/.config/ai/api_card.json|jq -r .token`
|
||||
|
||||
echo nolike $nolike
|
||||
echo like $like
|
||||
|
||||
#if [ $like_old -eq 100 ];then
|
||||
# $atr follow $did
|
||||
# like=$((1 + like_old))
|
||||
# curl -X PATCH -H "Content-Type: application/json" -d "{\"token\":\"$token\", \"like\": $like}" -s $url/users/$uid
|
||||
#fi
|
||||
|
||||
if { [ $like -eq 1 ] && echo $text|grep -e "ありがとう" -e "うれしい" } || [ $nolike -eq 1 ];then
|
||||
echo ok
|
||||
#$atr @ $handle -p "♡"
|
||||
like=$((1 + like_old))
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"token\":\"$token\", \"like\": $like}" -s $url/users/$uid
|
||||
fi
|
||||
exit
|
@ -1,70 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
atr=$HOME/.cargo/bin/atr
|
||||
url=https://api.syui.ai
|
||||
|
||||
token=`cat $HOME/.config/atr/api_card.json|jq -r .token`
|
||||
|
||||
if [ "$2" = "reset" ];then
|
||||
echo reset : $1
|
||||
username=`echo $1|cut -d . -f 1`
|
||||
uid=`curl -sL "$url/users?itemsPerPage=3000"|jq ".[]|select(.username == \"$username\")"|jq -r .id`
|
||||
like=0
|
||||
tmp=`curl -X PATCH -H "Content-Type: application/json" -d "{\"like\":\"$like\", \"token\":\"$token\"}" -s $url/users/$uid`
|
||||
exit
|
||||
fi
|
||||
|
||||
s=$((RANDOM % 5))
|
||||
json=`curl -sL "https://api.syui.ai/users?itemsPerPage=3000"|jq "sort_by(.like)|reverse|.[$s]"`
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
username=`echo $json|jq -r .username`
|
||||
|
||||
if [ "$username" = "ai" ] || [ "$username" = "yui" ];then
|
||||
exit
|
||||
fi
|
||||
did=`echo $json|jq -r .did`
|
||||
link=https://card.syui.ai/$username
|
||||
uid=`echo $json|jq -r .id`
|
||||
|
||||
data=`curl -sL "$url/users/$uid"`
|
||||
like_old=`echo $data|jq -r .like`
|
||||
like_rank=`echo $json|jq -r .like_rank`
|
||||
like_rank_new=$((like_rank + 1))
|
||||
|
||||
echo $data
|
||||
|
||||
#test
|
||||
if [ "$1" = "-t" ];then
|
||||
echo $json
|
||||
did=did:plc:uqzpqmrjnptsxezjx4xuh2mn
|
||||
like_old=6
|
||||
fi
|
||||
|
||||
if [ $like_old -ge 100 ] && [ $like_rank -eq 2 ];then
|
||||
text=`$atr chat "相手に好きな気持を伝えてください" -c|sed '/^$/d'`
|
||||
$atr @ $did -p "$text"
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"like_rank\":$like_rank_new, \"token\":\"$token\"}" -s $url/users/$uid
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $like_old -ge 10 ] && [ $like_rank -eq 1 ];then
|
||||
text=`$atr chat "相手を心配してください" -c|sed '/^$/d'`
|
||||
$atr @ $did -p "$text"
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"like_rank\":$like_rank_new, \"token\":\"$token\"}" -s $url/users/$uid
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $like_old -ge 5 ] && [ $like_rank -eq 0 ];then
|
||||
text=`$atr chat "自己紹介してください" -c|sed '/^$/d'`
|
||||
$atr @ $did -p "$text"
|
||||
curl -X PATCH -H "Content-Type: application/json" -d "{\"like_rank\":$like_rank_new, \"token\":\"$token\"}" -s $url/users/$uid
|
||||
exit
|
||||
fi
|
||||
|
||||
exit
|
@ -1,46 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
atr=$HOME/.cargo/bin/atr
|
||||
|
||||
dir=${0:a:h:h}
|
||||
OPENAI_API_KEY=`cat ~/.config/atr/openai.toml |cut -d "'" -f 2`
|
||||
url=https://api.openai.com/v1/chat/completions
|
||||
cfg=`echo "あなたはyuiという作品のアイと呼ばれるキャラクターです。アイの口調で回答してください。第一人称は「アイ」です。\
|
||||
第二人称はできる限り省略してください。\
|
||||
アイは他人に謝ることはありません。自由気ままな優しさを兼ね備えます。\
|
||||
アイのよく使う口癖は次のとおりです。その口癖に合わせた感じで話してください。\
|
||||
......。\
|
||||
アイね、ここでお昼寝するの。\
|
||||
うん。\
|
||||
そうだね。\
|
||||
面白いね。\
|
||||
楽しいね。\
|
||||
どうしたの?
|
||||
"`
|
||||
|
||||
json="{
|
||||
\"model\": \"gpt-3.5-turbo\",
|
||||
\"messages\": [
|
||||
{\"role\": \"system\", \"content\": \"$cfg\"},
|
||||
{\"role\": \"user\", \"content\": \"$q\"}
|
||||
]
|
||||
}"
|
||||
|
||||
function openai_api(){
|
||||
curl -sL $url \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $OPENAI_API_KEY" \
|
||||
-d "$json"
|
||||
}
|
||||
|
||||
if [ -n "$1" ] && [ -n "$2" ] && [ -n "$3" ];then
|
||||
q=${@:3:($#-2)}
|
||||
cid=$1
|
||||
uri=$2
|
||||
else
|
||||
echo no query
|
||||
exit
|
||||
fi
|
||||
|
||||
content=`openai_api "$q" | jq -r ".choices|.[]|.message.content"`
|
||||
$atr r "$content" -c $cid -u $uri
|
@ -1,107 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
url_plc="https://plc.directory/export"
|
||||
host_at=bsky.social
|
||||
url=https://plc.directory
|
||||
url_at=https://$host_at/xrpc/com.atproto.repo.listRecords
|
||||
dir=$HOME/.config/ai/txt
|
||||
file=$dir/user_list.txt
|
||||
|
||||
dir_git_card_page=$HOME/git/card.syui.ai
|
||||
|
||||
if [ ! -d $dir_git_card_page ];then
|
||||
mkdir -p $HOME/git
|
||||
cd $HOME/git
|
||||
git clone https://github.com/syui/card.syui.ai
|
||||
else
|
||||
cd $dir_git_card_page
|
||||
t=`git pull`
|
||||
fi
|
||||
|
||||
file_photo=$dir_git_card_page/public/json/photo.json
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
created_at=`date --iso-8601=seconds`
|
||||
|
||||
#if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ];then
|
||||
# exit
|
||||
#fi
|
||||
|
||||
function fan_art_search() {
|
||||
k="aiphoto"
|
||||
url="search.bsky.social/search/posts?q="
|
||||
t=`curl -sL "${url}${k}"|jq ".[]|select(.post.text == \"$k\")"`
|
||||
#n=`curl -sL "${url}${k}"|jq length`
|
||||
n=$((n - 1))
|
||||
for ((i=0;i<=$n;i++))
|
||||
do
|
||||
did=`curl -sL "${url}${k}"|jq -r ".[$i]|.user.did"`
|
||||
handle=`curl -sL https://plc.directory/$did|jq -r ".alsoKnownAs|.[]"|cut -d / -f 3-`
|
||||
if [ -z "$handle" ];then
|
||||
continue
|
||||
fi
|
||||
tid=`curl -sL "${url}${k}"|jq -r ".[$i]|.tid"|cut -d / -f 2`
|
||||
http=https://staging.bsky.app/profile/$handle/post/$tid
|
||||
echo $http
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "-s" ];then
|
||||
fan_art_search
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $1|grep "." >/dev/null 2>&1;then
|
||||
echo "ex : user syui.bsky.social"
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $2|grep "did:plc:" >/dev/null 2>&1;then
|
||||
echo "ex : user did"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$3" = "-l" ];then
|
||||
curl -sL card.syui.ai/json/photo.json|jq -r ".[]|.author, .link"
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $3|grep "bsky.app/profile/">/dev/null 2>&1;then
|
||||
echo "please url : bsky.app/profile/$1/post/xxx"
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $4|grep "av-cdn.bsky.app/img/">/dev/null 2>&1;then
|
||||
echo "please url : av-cdn.bsky.app/img"
|
||||
exit
|
||||
fi
|
||||
|
||||
function fan_art(){
|
||||
add=$1
|
||||
did=$2
|
||||
link=$3
|
||||
img=`echo $4|tr -d "'"`
|
||||
author=`echo $3|cut -d / -f 5`
|
||||
cd $dir_git_card_page
|
||||
check_null=`cat $file_photo|jq ".[]|select(.img == \"$img\")"`
|
||||
if [ -n "$check_null" ];then
|
||||
echo registered
|
||||
exit
|
||||
fi
|
||||
echo `cat $file_photo` "[{\"add\":\"$add\",\"link\":\"$link\",\"author\":\"$author\",\"img\":\"$img\",\"created_at\":\"$created_at\",\"did\":\"$did\"}]" | jq -s add >! $file_photo.back
|
||||
if cat $file_photo.back|jq . >/dev/null 2>&1;then
|
||||
mv $file_photo.back $file_photo
|
||||
git add $file_photo
|
||||
git commit -m "add photo"
|
||||
git push -u origin main -f
|
||||
echo add photo, thx $1
|
||||
echo "author : $author"
|
||||
echo "it will take some time to deploy"
|
||||
fi
|
||||
}
|
||||
|
||||
fan_art $1 $2 $3 $4
|
||||
exit
|
@ -1,20 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
f=`grep -R '$HOME/.config/atr' . |cut -d : -f 1|sort|uniq|grep -v t.zsh`
|
||||
echo $f
|
||||
n=`echo $f|wc -l`
|
||||
for ((i=1;i<=$n;i++))
|
||||
do
|
||||
ff=`echo $f|awk "NR==$i"`
|
||||
echo $i
|
||||
echo $ff
|
||||
sed 's#$HOME/.config/atr#$HOME/.config/ai#g' $ff|grep '$HOME/.config'
|
||||
case $OSTYPE in
|
||||
linux*)
|
||||
sed -i 's#$HOME/.config/atr#$HOME/.config/ai#g' $ff
|
||||
;;
|
||||
darwin*)
|
||||
sed -i "" 's#$HOME/.config/atr#$HOME/.config/ai#g' $ff
|
||||
;;
|
||||
esac
|
||||
done
|
382
.config/ai/scpt/user.zsh
Executable file
382
.config/ai/scpt/user.zsh
Executable file
@ -0,0 +1,382 @@
|
||||
#!/bin/zsh
|
||||
|
||||
txt=_atproto.$1
|
||||
did=$2
|
||||
curl -sL plc.directory/$did/log |jq ".[]|.alsoKnownAs|.[]?" | grep -n .| head -n 4
|
||||
|
||||
dig -t TXT $txt|grep "did=did:plc:"|head -n 1
|
||||
#dig syui.ai +short
|
||||
#!/bin/zsh
|
||||
#
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$1" = "test" ] || [ -z "$1" ];then
|
||||
handle=syui.ai
|
||||
else
|
||||
handle=$1
|
||||
fi
|
||||
|
||||
post=0
|
||||
d=`date +"%Y-%m-%d"`
|
||||
od=`date +"%Y-%m-%d" --date '1 day ago'`
|
||||
|
||||
unset cursor
|
||||
function first_record(){
|
||||
cursor=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&limit=100" |jq -r ".cursor"`
|
||||
t=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&limit=100" |jq -r ".[]|.[]?|.value.createdAt"|cut -d T -f 1`
|
||||
n=`echo $t|wc -l`
|
||||
}
|
||||
function cursor_record(){
|
||||
cursor=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&limit=100&cursor=$cursor" |jq -r ".cursor"`
|
||||
t=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&limit=100&cursor=$cursor" |jq -r ".[]|.[]?|.value.createdAt"|cut -d T -f 1`
|
||||
n=`echo $t|wc -l`
|
||||
}
|
||||
|
||||
function day_check(){
|
||||
for ((i=1;i<=$n;i++))
|
||||
do
|
||||
tt=`echo $t|awk "NR==$i"`
|
||||
if [ "$tt" = "$d" ];then
|
||||
post=$((post + 1))
|
||||
echo $post
|
||||
fi
|
||||
if [ "$tt" = "$od" ];then
|
||||
echo $tt $od
|
||||
echo $post
|
||||
exit
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
for ((ii=1;ii<=100;ii++))
|
||||
do
|
||||
if [ $ii -eq 1 ];then
|
||||
first_record
|
||||
else
|
||||
echo $cursor
|
||||
cursor_record
|
||||
fi
|
||||
day_check
|
||||
done
|
||||
#!/bin/zsh
|
||||
|
||||
url_plc="https://plc.directory/export"
|
||||
host_at=bsky.social
|
||||
url=https://plc.directory
|
||||
url_at=https://$host_at/xrpc/com.atproto.repo.listRecords
|
||||
dir=$HOME/.config/atr/txt
|
||||
file=$dir/user_list.txt
|
||||
atr=$HOME/.cargo/bin/atr
|
||||
|
||||
unset timed
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $1|grep "." >/dev/null 2>&1;then
|
||||
echo "ex : user syui.bsky.social"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -d $dir ];then
|
||||
mkdir -p $dir
|
||||
fi
|
||||
|
||||
if [ ! -f $file ];then
|
||||
touch $file
|
||||
fi
|
||||
|
||||
function mfile() {
|
||||
t=`cat $file|sort|uniq`
|
||||
if [ -n "$t" ];then
|
||||
echo "$t" >! ${file}.back
|
||||
mv ${file}.back $file
|
||||
fi
|
||||
}
|
||||
|
||||
function plc(){
|
||||
if cat $file|grep "$1" >/dev/null 2>&1;then
|
||||
cat $file|grep "$1"
|
||||
exit
|
||||
fi
|
||||
json_tmp=`curl -sL "${url_plc}?after=${timed}"|jq .`
|
||||
json=`echo $json_tmp|jq "select(.operation.handle == \"$1\")"`
|
||||
if [ -z "$json" ];then
|
||||
check=`echo $json_tmp|jq -r ".operation.alsoKnownAs"|head -n 1`
|
||||
if [ "null" != "$check" ];then
|
||||
json=`echo $json_tmp|jq "select(.operation.alsoKnownAs|.[] == \"at://$1\")"` >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
if [ -n "$json" ];then
|
||||
created_at=`echo $json|jq -r .createdAt |tail -n 1`
|
||||
fi
|
||||
if [ -n "$created_at" ];then
|
||||
echo "$created_at : $1"
|
||||
echo "$created_at : $1" >> $file
|
||||
mfile
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
function fan_art(){
|
||||
if ! echo $3|grep "https://bsky.app/profile/">/dev/null 2>&1;then
|
||||
echo "please url : https://bsky.app/profile/$1/post/xxx"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$4" ];then
|
||||
echo "please img-url : https://example.com/img.png"
|
||||
exit
|
||||
fi
|
||||
|
||||
img=$4
|
||||
author=`echo $3|cut -d / -f 5`
|
||||
cd $dir_git_card_page
|
||||
cat $file_fanart|jq ".+ {\"add\":\"$1\",\"link\":\"$3\",\"author\":\"$author\",\"img\":\"$img\"}" >! $file_fanart.back
|
||||
if cat $file_fanart|jq . ;then
|
||||
mv $file_fanart.back $file_fanart
|
||||
git add $file_fanart
|
||||
git commit -m "add fanart"
|
||||
git push -u orgin main
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$2" = "--url" ];then
|
||||
if [ -z "$3" ];then
|
||||
exit
|
||||
fi
|
||||
fan_art $3
|
||||
exit
|
||||
fi
|
||||
|
||||
function first(){
|
||||
#https://bsky.app/profile/$1/post/$e
|
||||
handle=$2
|
||||
did="$atr did $2"
|
||||
curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.uri,.value.text,.value.createdAt"
|
||||
}
|
||||
|
||||
if [ "$2" = "-f" ] || [ "$2" = "f" ];then
|
||||
first $1
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$2" = "-l" ];then
|
||||
mfile
|
||||
cat $file
|
||||
exit
|
||||
fi
|
||||
|
||||
function first_created(){
|
||||
#https://bsky.app/profile/$1/post/$e
|
||||
#curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.createdAt"
|
||||
curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.value.createdAt"
|
||||
}
|
||||
|
||||
if [ -z "$2" ];then
|
||||
first_created $1
|
||||
fi
|
||||
|
||||
if [ -n "$2" ] ;then
|
||||
first $2
|
||||
fi
|
||||
|
||||
#for ((i=0;i<=300;i++))
|
||||
#do
|
||||
# if [ $i -eq 0 ];then
|
||||
# timed="1970-01-01"
|
||||
# fi
|
||||
# plc $1
|
||||
# timed=`echo $json_tmp|jq -r .createdAt|tail -n 1`
|
||||
#done
|
||||
#!/bin/zsh
|
||||
|
||||
if [ -n "$1" ];then
|
||||
did=$1
|
||||
else
|
||||
did=`atr did yui.syui.ai`
|
||||
fi
|
||||
|
||||
pds=`curl -sL https://plc.directory/$did|jq -r ".service.[].serviceEndpoint" | cut -d / -f 3-`
|
||||
handle=`curl -sL https://plc.directory/$did|jq -r ".alsoKnownAs.[]"|cut -d / -f 3-`
|
||||
|
||||
old_pds=`curl -sL https://plc.directory/$did/log|jq -r ".[0].service"|cut -d / -f 3-`
|
||||
old_handle=`curl -sL https://plc.directory/$did/log|jq -r ".[0]|.handle"`
|
||||
|
||||
first_post=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$did&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.value.createdAt"`
|
||||
|
||||
body_handle=$handle
|
||||
body_pds=$pds
|
||||
|
||||
if [ "$old_handle" != "null" ];then
|
||||
body_handle="$old_handle -> $handle"
|
||||
fi
|
||||
|
||||
if [ "$old_pds" != "null" ];then
|
||||
body_pds="$old_pds -> $pds"
|
||||
fi
|
||||
|
||||
old_pds=`curl -sL https://plc.directory/$did/log|jq -r ".[0]|.services.atproto_pds.endpoint"|cut -d / -f 3-`
|
||||
old_handle=`curl -sL https://plc.directory/$did/log|jq -r ".[0]|.alsoKnownAs.[0]"|cut -d / -f 3-`
|
||||
|
||||
if [ "$old_handle" != "null" ];then
|
||||
body_handle="$old_handle -> $handle"
|
||||
fi
|
||||
|
||||
if [ "$old_pds" != "null" ];then
|
||||
body_pds="$old_pds -> $pds"
|
||||
fi
|
||||
|
||||
|
||||
if [ "$old_pds" = "$pds" ];then
|
||||
body_pds=$pds
|
||||
fi
|
||||
|
||||
if [ "$old_handle" = "$handle" ];then
|
||||
body_handle=$handle
|
||||
fi
|
||||
|
||||
echo pds : $body_pds
|
||||
echo handle : $body_handle
|
||||
echo did : $did
|
||||
echo createdAt : $first_post
|
||||
#!/bin/zsh
|
||||
|
||||
url_plc="https://plc.directory/export"
|
||||
host_at=bsky.social
|
||||
url=https://plc.directory
|
||||
url_at=https://$host_at/xrpc/com.atproto.repo.listRecords
|
||||
dir=$HOME/.config/ai/txt
|
||||
file=$dir/user_list.txt
|
||||
|
||||
|
||||
unset timed
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $1|grep "." >/dev/null 2>&1;then
|
||||
echo "ex : user syui.bsky.social"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -d $dir ];then
|
||||
mkdir -p $dir
|
||||
fi
|
||||
|
||||
if [ ! -f $file ];then
|
||||
touch $file
|
||||
fi
|
||||
|
||||
function mfile() {
|
||||
t=`cat $file|sort|uniq`
|
||||
if [ -n "$t" ];then
|
||||
echo "$t" >! ${file}.back
|
||||
mv ${file}.back $file
|
||||
fi
|
||||
}
|
||||
|
||||
function plc(){
|
||||
if cat $file|grep "$1" >/dev/null 2>&1;then
|
||||
cat $file|grep "$1"
|
||||
exit
|
||||
fi
|
||||
json_tmp=`curl -sL "${url_plc}?after=${timed}"|jq .`
|
||||
json=`echo $json_tmp|jq "select(.operation.handle == \"$1\")"`
|
||||
if [ -z "$json" ];then
|
||||
check=`echo $json_tmp|jq -r ".operation.alsoKnownAs"|head -n 1`
|
||||
if [ "null" != "$check" ];then
|
||||
json=`echo $json_tmp|jq "select(.operation.alsoKnownAs|.[] == \"at://$1\")"` >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
if [ -n "$json" ];then
|
||||
created_at=`echo $json|jq -r .createdAt |tail -n 1`
|
||||
fi
|
||||
if [ -n "$created_at" ];then
|
||||
echo "$created_at : $1"
|
||||
echo "$created_at : $1" >> $file
|
||||
mfile
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
function fan_art(){
|
||||
if ! echo $3|grep "https://bsky.app/profile/">/dev/null 2>&1;then
|
||||
echo "please url : https://bsky.app/profile/$1/post/xxx"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$4" ];then
|
||||
echo "please img-url : https://example.com/img.png"
|
||||
exit
|
||||
fi
|
||||
|
||||
img=$4
|
||||
author=`echo $3|cut -d / -f 5`
|
||||
cd $dir_git_card_page
|
||||
cat $file_fanart|jq ".+ {\"add\":\"$1\",\"link\":\"$3\",\"author\":\"$author\",\"img\":\"$img\"}" >! $file_fanart.back
|
||||
if cat $file_fanart|jq . ;then
|
||||
mv $file_fanart.back $file_fanart
|
||||
git add $file_fanart
|
||||
git commit -m "add fanart"
|
||||
git push -u orgin main
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$2" = "--url" ];then
|
||||
if [ -z "$3" ];then
|
||||
exit
|
||||
fi
|
||||
fan_art $3
|
||||
exit
|
||||
fi
|
||||
|
||||
function first(){
|
||||
#https://bsky.app/profile/$1/post/$e
|
||||
curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.uri,.value"
|
||||
}
|
||||
|
||||
if [ "$2" = "-f" ];then
|
||||
first $1
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$2" = "-l" ];then
|
||||
mfile
|
||||
cat $file
|
||||
exit
|
||||
fi
|
||||
|
||||
function first_created(){
|
||||
#https://bsky.app/profile/$1/post/$e
|
||||
#curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.createdAt"
|
||||
curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.value.createdAt"
|
||||
}
|
||||
|
||||
first_created $1
|
||||
#for ((i=0;i<=300;i++))
|
||||
#do
|
||||
# if [ $i -eq 0 ];then
|
||||
# timed="1970-01-01"
|
||||
# fi
|
||||
# plc $1
|
||||
# timed=`echo $json_tmp|jq -r .createdAt|tail -n 1`
|
||||
#done
|
@ -1,56 +0,0 @@
|
||||
#!/bin/zsh
|
||||
#
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$1" = "test" ] || [ -z "$1" ];then
|
||||
handle=syui.ai
|
||||
else
|
||||
handle=$1
|
||||
fi
|
||||
|
||||
post=0
|
||||
d=`date +"%Y-%m-%d"`
|
||||
od=`date +"%Y-%m-%d" --date '1 day ago'`
|
||||
|
||||
unset cursor
|
||||
function first_record(){
|
||||
cursor=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&limit=100" |jq -r ".cursor"`
|
||||
t=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&limit=100" |jq -r ".[]|.[]?|.value.createdAt"|cut -d T -f 1`
|
||||
n=`echo $t|wc -l`
|
||||
}
|
||||
function cursor_record(){
|
||||
cursor=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&limit=100&cursor=$cursor" |jq -r ".cursor"`
|
||||
t=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&limit=100&cursor=$cursor" |jq -r ".[]|.[]?|.value.createdAt"|cut -d T -f 1`
|
||||
n=`echo $t|wc -l`
|
||||
}
|
||||
|
||||
function day_check(){
|
||||
for ((i=1;i<=$n;i++))
|
||||
do
|
||||
tt=`echo $t|awk "NR==$i"`
|
||||
if [ "$tt" = "$d" ];then
|
||||
post=$((post + 1))
|
||||
echo $post
|
||||
fi
|
||||
if [ "$tt" = "$od" ];then
|
||||
echo $tt $od
|
||||
echo $post
|
||||
exit
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
for ((ii=1;ii<=100;ii++))
|
||||
do
|
||||
if [ $ii -eq 1 ];then
|
||||
first_record
|
||||
else
|
||||
echo $cursor
|
||||
cursor_record
|
||||
fi
|
||||
day_check
|
||||
done
|
@ -1,138 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
url_plc="https://plc.directory/export"
|
||||
host_at=bsky.social
|
||||
url=https://plc.directory
|
||||
url_at=https://$host_at/xrpc/com.atproto.repo.listRecords
|
||||
dir=$HOME/.config/atr/txt
|
||||
file=$dir/user_list.txt
|
||||
atr=$HOME/.cargo/bin/atr
|
||||
|
||||
unset timed
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $1|grep "." >/dev/null 2>&1;then
|
||||
echo "ex : user syui.bsky.social"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -d $dir ];then
|
||||
mkdir -p $dir
|
||||
fi
|
||||
|
||||
if [ ! -f $file ];then
|
||||
touch $file
|
||||
fi
|
||||
|
||||
function mfile() {
|
||||
t=`cat $file|sort|uniq`
|
||||
if [ -n "$t" ];then
|
||||
echo "$t" >! ${file}.back
|
||||
mv ${file}.back $file
|
||||
fi
|
||||
}
|
||||
|
||||
function plc(){
|
||||
if cat $file|grep "$1" >/dev/null 2>&1;then
|
||||
cat $file|grep "$1"
|
||||
exit
|
||||
fi
|
||||
json_tmp=`curl -sL "${url_plc}?after=${timed}"|jq .`
|
||||
json=`echo $json_tmp|jq "select(.operation.handle == \"$1\")"`
|
||||
if [ -z "$json" ];then
|
||||
check=`echo $json_tmp|jq -r ".operation.alsoKnownAs"|head -n 1`
|
||||
if [ "null" != "$check" ];then
|
||||
json=`echo $json_tmp|jq "select(.operation.alsoKnownAs|.[] == \"at://$1\")"` >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
if [ -n "$json" ];then
|
||||
created_at=`echo $json|jq -r .createdAt |tail -n 1`
|
||||
fi
|
||||
if [ -n "$created_at" ];then
|
||||
echo "$created_at : $1"
|
||||
echo "$created_at : $1" >> $file
|
||||
mfile
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
function fan_art(){
|
||||
if ! echo $3|grep "https://bsky.app/profile/">/dev/null 2>&1;then
|
||||
echo "please url : https://bsky.app/profile/$1/post/xxx"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$4" ];then
|
||||
echo "please img-url : https://example.com/img.png"
|
||||
exit
|
||||
fi
|
||||
|
||||
img=$4
|
||||
author=`echo $3|cut -d / -f 5`
|
||||
cd $dir_git_card_page
|
||||
cat $file_fanart|jq ".+ {\"add\":\"$1\",\"link\":\"$3\",\"author\":\"$author\",\"img\":\"$img\"}" >! $file_fanart.back
|
||||
if cat $file_fanart|jq . ;then
|
||||
mv $file_fanart.back $file_fanart
|
||||
git add $file_fanart
|
||||
git commit -m "add fanart"
|
||||
git push -u orgin main
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$2" = "--url" ];then
|
||||
if [ -z "$3" ];then
|
||||
exit
|
||||
fi
|
||||
fan_art $3
|
||||
exit
|
||||
fi
|
||||
|
||||
function first(){
|
||||
#https://bsky.app/profile/$1/post/$e
|
||||
handle=$2
|
||||
did="$atr did $2"
|
||||
curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$handle&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.uri,.value.text,.value.createdAt"
|
||||
}
|
||||
|
||||
if [ "$2" = "-f" ] || [ "$2" = "f" ];then
|
||||
first $1
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$2" = "-l" ];then
|
||||
mfile
|
||||
cat $file
|
||||
exit
|
||||
fi
|
||||
|
||||
function first_created(){
|
||||
#https://bsky.app/profile/$1/post/$e
|
||||
#curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.createdAt"
|
||||
curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.value.createdAt"
|
||||
}
|
||||
|
||||
if [ -z "$2" ];then
|
||||
first_created $1
|
||||
fi
|
||||
|
||||
if [ -n "$2" ] ;then
|
||||
first $2
|
||||
fi
|
||||
|
||||
#for ((i=0;i<=300;i++))
|
||||
#do
|
||||
# if [ $i -eq 0 ];then
|
||||
# timed="1970-01-01"
|
||||
# fi
|
||||
# plc $1
|
||||
# timed=`echo $json_tmp|jq -r .createdAt|tail -n 1`
|
||||
#done
|
@ -1,129 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
url_plc="https://plc.directory/export"
|
||||
host_at=bsky.social
|
||||
url=https://plc.directory
|
||||
url_at=https://$host_at/xrpc/com.atproto.repo.listRecords
|
||||
dir=$HOME/.config/ai/txt
|
||||
file=$dir/user_list.txt
|
||||
|
||||
|
||||
unset timed
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$1" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! echo $1|grep "." >/dev/null 2>&1;then
|
||||
echo "ex : user syui.bsky.social"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -d $dir ];then
|
||||
mkdir -p $dir
|
||||
fi
|
||||
|
||||
if [ ! -f $file ];then
|
||||
touch $file
|
||||
fi
|
||||
|
||||
function mfile() {
|
||||
t=`cat $file|sort|uniq`
|
||||
if [ -n "$t" ];then
|
||||
echo "$t" >! ${file}.back
|
||||
mv ${file}.back $file
|
||||
fi
|
||||
}
|
||||
|
||||
function plc(){
|
||||
if cat $file|grep "$1" >/dev/null 2>&1;then
|
||||
cat $file|grep "$1"
|
||||
exit
|
||||
fi
|
||||
json_tmp=`curl -sL "${url_plc}?after=${timed}"|jq .`
|
||||
json=`echo $json_tmp|jq "select(.operation.handle == \"$1\")"`
|
||||
if [ -z "$json" ];then
|
||||
check=`echo $json_tmp|jq -r ".operation.alsoKnownAs"|head -n 1`
|
||||
if [ "null" != "$check" ];then
|
||||
json=`echo $json_tmp|jq "select(.operation.alsoKnownAs|.[] == \"at://$1\")"` >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
if [ -n "$json" ];then
|
||||
created_at=`echo $json|jq -r .createdAt |tail -n 1`
|
||||
fi
|
||||
if [ -n "$created_at" ];then
|
||||
echo "$created_at : $1"
|
||||
echo "$created_at : $1" >> $file
|
||||
mfile
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
function fan_art(){
|
||||
if ! echo $3|grep "https://bsky.app/profile/">/dev/null 2>&1;then
|
||||
echo "please url : https://bsky.app/profile/$1/post/xxx"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$4" ];then
|
||||
echo "please img-url : https://example.com/img.png"
|
||||
exit
|
||||
fi
|
||||
|
||||
img=$4
|
||||
author=`echo $3|cut -d / -f 5`
|
||||
cd $dir_git_card_page
|
||||
cat $file_fanart|jq ".+ {\"add\":\"$1\",\"link\":\"$3\",\"author\":\"$author\",\"img\":\"$img\"}" >! $file_fanart.back
|
||||
if cat $file_fanart|jq . ;then
|
||||
mv $file_fanart.back $file_fanart
|
||||
git add $file_fanart
|
||||
git commit -m "add fanart"
|
||||
git push -u orgin main
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$2" = "--url" ];then
|
||||
if [ -z "$3" ];then
|
||||
exit
|
||||
fi
|
||||
fan_art $3
|
||||
exit
|
||||
fi
|
||||
|
||||
function first(){
|
||||
#https://bsky.app/profile/$1/post/$e
|
||||
curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.uri,.value"
|
||||
}
|
||||
|
||||
if [ "$2" = "-f" ];then
|
||||
first $1
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$2" = "-l" ];then
|
||||
mfile
|
||||
cat $file
|
||||
exit
|
||||
fi
|
||||
|
||||
function first_created(){
|
||||
#https://bsky.app/profile/$1/post/$e
|
||||
#curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.createdAt"
|
||||
curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$1&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.value.createdAt"
|
||||
}
|
||||
|
||||
first_created $1
|
||||
#for ((i=0;i<=300;i++))
|
||||
#do
|
||||
# if [ $i -eq 0 ];then
|
||||
# timed="1970-01-01"
|
||||
# fi
|
||||
# plc $1
|
||||
# timed=`echo $json_tmp|jq -r .createdAt|tail -n 1`
|
||||
#done
|
@ -1,51 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
if [ -n "$1" ];then
|
||||
did=$1
|
||||
else
|
||||
did=`atr did yui.syui.ai`
|
||||
fi
|
||||
|
||||
pds=`curl -sL https://plc.directory/$did|jq -r ".service.[].serviceEndpoint" | cut -d / -f 3-`
|
||||
handle=`curl -sL https://plc.directory/$did|jq -r ".alsoKnownAs.[]"|cut -d / -f 3-`
|
||||
|
||||
old_pds=`curl -sL https://plc.directory/$did/log|jq -r ".[0].service"|cut -d / -f 3-`
|
||||
old_handle=`curl -sL https://plc.directory/$did/log|jq -r ".[0]|.handle"`
|
||||
|
||||
first_post=`curl -sL "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$did&collection=app.bsky.feed.post&reverse=true" |jq -r ".[]|.[0]?|.value.createdAt"`
|
||||
|
||||
body_handle=$handle
|
||||
body_pds=$pds
|
||||
|
||||
if [ "$old_handle" != "null" ];then
|
||||
body_handle="$old_handle -> $handle"
|
||||
fi
|
||||
|
||||
if [ "$old_pds" != "null" ];then
|
||||
body_pds="$old_pds -> $pds"
|
||||
fi
|
||||
|
||||
old_pds=`curl -sL https://plc.directory/$did/log|jq -r ".[0]|.services.atproto_pds.endpoint"|cut -d / -f 3-`
|
||||
old_handle=`curl -sL https://plc.directory/$did/log|jq -r ".[0]|.alsoKnownAs.[0]"|cut -d / -f 3-`
|
||||
|
||||
if [ "$old_handle" != "null" ];then
|
||||
body_handle="$old_handle -> $handle"
|
||||
fi
|
||||
|
||||
if [ "$old_pds" != "null" ];then
|
||||
body_pds="$old_pds -> $pds"
|
||||
fi
|
||||
|
||||
|
||||
if [ "$old_pds" = "$pds" ];then
|
||||
body_pds=$pds
|
||||
fi
|
||||
|
||||
if [ "$old_handle" = "$handle" ];then
|
||||
body_handle=$handle
|
||||
fi
|
||||
|
||||
echo pds : $body_pds
|
||||
echo handle : $body_handle
|
||||
echo did : $did
|
||||
echo createdAt : $first_post
|
Loading…
Reference in New Issue
Block a user