v0.1
This commit is contained in:
.config
.gitignoreCargo.tomlDockerfileREADME.mdai.zshdocs
icon
scpt
api_card.zshapi_card_raid_win.zshapi_chara.zshapi_egg.zshapi_fav.zshapi_gift.zshapi_ten.zshapi_ten_auto.zshapi_ten_su_reset.zsharch.zshat_img.zshat_search.zshbluesky.zshbot_card.zshbot_kawaii.zshbot_list.zshbsky_token.zshcard_box.zshcard_fortune.zshcard_fortune_en.zshcard_pay.zshcard_tarot.zshcard_tarot_en.zshdiffusers.zshdig.zshfan_art.zshfollow_all.zshfull_moon.jinvite.zshlike_reply.zshmastodon.zshnyancat.zshnyancat_post.zshopenai_like.zshopenai_like_bot.zshopenai_like_timeline.zshphoto.zshstable_diffusion_prompt.juser_day_post.zshuser_list.zshuser_search.zshuser_service.zsh
src
ascii.rsbot.rsdata.rsdescribe.rsfollow.rsfollowers.rsfollows.rsimg.rsimg_reply.rsimg_upload.rslike.rsmain.rsmention.rsnotify.rsnotify_read.rsopenai.rspost.rspost_link.rsprofile.rsrefresh.rsreply.rsreply_link.rsreply_og.rsrepost.rssession.rstimeline_author.rstoken.rs
test
278
scpt/api_gift.zsh
Executable file
278
scpt/api_gift.zsh
Executable file
@@ -0,0 +1,278 @@
|
||||
#!/bin/zsh
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias date="/opt/homebrew/bin/gdate"
|
||||
;;
|
||||
esac
|
||||
|
||||
atr=$HOME/.cargo/bin/atr
|
||||
host=https://api.syui.ai
|
||||
|
||||
pass=`cat $HOME/.config/atr/api_card.json|jq -r .password`
|
||||
token=`cat $HOME/.config/atr/api_card.json|jq -r .token`
|
||||
|
||||
handle=$1
|
||||
did=$2
|
||||
username=`echo $1|cut -d . -f 1`
|
||||
cid=`echo $3|cut -d ' ' -f 1`
|
||||
guser=$4
|
||||
|
||||
if [ "$3" = "ai" ];then
|
||||
guser=ai
|
||||
fi
|
||||
|
||||
if [ -z "$cid" ];then
|
||||
echo no option
|
||||
echo "---"
|
||||
echo "@yui.syui.ai /gift ai"
|
||||
echo "---"
|
||||
echo "@yui.syui.ai /gift status"
|
||||
echo "12345"
|
||||
echo "67891"
|
||||
echo "---"
|
||||
echo "@yui.syui.ai /gift 12345"
|
||||
echo ""
|
||||
echo "---"
|
||||
echo "@yui.syui.ai /gift 12345 syui"
|
||||
exit
|
||||
fi
|
||||
|
||||
function card_env(){
|
||||
all_data=`curl -sL "$host/users?itemsPerPage=3000"`
|
||||
data=`echo $all_data|jq ".[]|select(.username == \"$username\")"`
|
||||
gdata=`echo $all_data|jq ".[]|select(.username == \"$guser\")"`
|
||||
if [ -z "$data" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
uid=`echo $data|jq -r .id`
|
||||
gid=`echo $gdata|jq -r .id`
|
||||
|
||||
aiten=`echo $data|jq -r .aiten`
|
||||
fav=`echo $data|jq -r .fav`
|
||||
|
||||
cdata=`curl -sL $host/cards/$cid`
|
||||
if [ -z "$cdata" ];then
|
||||
echo no card
|
||||
exit
|
||||
fi
|
||||
|
||||
card=`echo $cdata|jq -r .card`
|
||||
cp=`echo $cdata|jq -r .cp`
|
||||
count=`echo $cdata|jq -r .count`
|
||||
author=`echo $cdata|jq -r .author`
|
||||
skill=`echo $cdata|jq -r .skill`
|
||||
s=`echo $cdata|jq -r .status`
|
||||
|
||||
if [ $count -eq 0 ];then
|
||||
echo card count 0
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $author != "$username" ];then
|
||||
echo no author
|
||||
echo "$author --> $username"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
function card_env_ai(){
|
||||
guser=ai
|
||||
all_data=`curl -sL "$host/users?itemsPerPage=3000"`
|
||||
data=`echo $all_data|jq ".[]|select(.username == \"$username\")"`
|
||||
gdata=`echo $all_data|jq ".[]|select(.username == \"$guser\")"`
|
||||
if [ -z "$data" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
uid=`echo $data|jq -r .id`
|
||||
gid=`echo $gdata|jq -r .id`
|
||||
|
||||
aiten=`echo $data|jq -r .aiten`
|
||||
fav=`echo $data|jq -r .fav`
|
||||
|
||||
cdata=`curl -sL "$host/users/$uid/card?itemsPerPage=3000"|jq ".[0]"`
|
||||
if [ -z "$cdata" ];then
|
||||
cdata=`curl -sL "$host/users/$uid/card?itemsPerPage=3000"|jq ".[]|select(.author == \"$username\")"|jq -s ".[0]"`
|
||||
fi
|
||||
|
||||
if [ -z "$cdata" ];then
|
||||
echo no card
|
||||
exit
|
||||
fi
|
||||
|
||||
cid=`echo $cdata|jq -r .id`
|
||||
card=`echo $cdata|jq -r .card`
|
||||
cp=`echo $cdata|jq -r .cp`
|
||||
count=`echo $cdata|jq -r .count`
|
||||
author=`echo $cdata|jq -r .author`
|
||||
skill=`echo $cdata|jq -r .skill`
|
||||
s=`echo $cdata|jq -r .status`
|
||||
|
||||
if [ $count -eq 0 ];then
|
||||
echo card count 0
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $author != "$username" ];then
|
||||
echo no author
|
||||
echo "$author --> $username"
|
||||
exit
|
||||
fi
|
||||
|
||||
aicard=`curl -sL "$host/users/$gid/card?itemsPerPage=3000"|jq -r ".[]|select(.card >= 1)"|jq -s`
|
||||
if [ -z "$aicard" ];then
|
||||
exit
|
||||
fi
|
||||
n=`echo $aicard|jq length`
|
||||
n=$((n - 1))
|
||||
ran=$((RANDOM % n))
|
||||
ai_id=`echo $aicard|jq -r ".[$ran]|.id"`
|
||||
ai_card=`echo $aicard|jq -r ".[$ran]|.card"`
|
||||
ai_cp=`echo $aicard|jq -r ".[$ran]|.cp"`
|
||||
ai_skill=`echo $aicard|jq -r ".[$ran]|.skill"`
|
||||
ai_s=`echo $aicard|jq -r ".[$ran]|.status"`
|
||||
ai_author=ai
|
||||
}
|
||||
|
||||
function card_env_ai_select(){
|
||||
all_data=`curl -sL "$host/users?itemsPerPage=3000"`
|
||||
data=`echo $all_data|jq ".[]|select(.username == \"$username\")"`
|
||||
gdata=`echo $all_data|jq ".[]|select(.username == \"$guser\")"`
|
||||
if [ -z "$data" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
uid=`echo $data|jq -r .id`
|
||||
gid=`echo $gdata|jq -r .id`
|
||||
|
||||
aiten=`echo $data|jq -r .aiten`
|
||||
fav=`echo $data|jq -r .fav`
|
||||
|
||||
cdata=`curl -sL $host/cards/$cid`
|
||||
if [ -z "$cdata" ];then
|
||||
echo no card
|
||||
exit
|
||||
fi
|
||||
|
||||
cid=`echo $cdata|jq -r .id`
|
||||
card=`echo $cdata|jq -r .card`
|
||||
cp=`echo $cdata|jq -r .cp`
|
||||
count=`echo $cdata|jq -r .count`
|
||||
author=`echo $cdata|jq -r .author`
|
||||
skill=`echo $cdata|jq -r .skill`
|
||||
s=`echo $cdata|jq -r .status`
|
||||
|
||||
if [ $count -eq 0 ];then
|
||||
echo card count 0
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $author != "$username" ];then
|
||||
echo no author
|
||||
echo "$author --> $username"
|
||||
exit
|
||||
fi
|
||||
|
||||
aicard=`curl -sL "$host/users/$gid/card?itemsPerPage=3000"|jq -r ".[]|select(.card >= 1)"|jq -s`
|
||||
if [ -z "$aicard" ];then
|
||||
exit
|
||||
fi
|
||||
n=`echo $aicard|jq length`
|
||||
n=$((n - 1))
|
||||
ran=$((RANDOM % n))
|
||||
ai_id=`echo $aicard|jq -r ".[$ran]|.id"`
|
||||
ai_card=`echo $aicard|jq -r ".[$ran]|.card"`
|
||||
ai_cp=`echo $aicard|jq -r ".[$ran]|.cp"`
|
||||
ai_skill=`echo $aicard|jq -r ".[$ran]|.skill"`
|
||||
ai_s=`echo $aicard|jq -r ".[$ran]|.status"`
|
||||
ai_author=ai
|
||||
}
|
||||
|
||||
function card_gift() {
|
||||
card_env
|
||||
if [ -z "$guser" ];then
|
||||
echo card:$card
|
||||
echo skill:$skill
|
||||
echo status:$s
|
||||
echo count:$count
|
||||
echo author:$author
|
||||
exit
|
||||
fi
|
||||
count=$((count - 1))
|
||||
tmp=`curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$gid,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\",\"author\":\"$username\",\"count\":0}" -sL $host/cards`
|
||||
tmp=`curl -X PATCH -H "Content-Type: application/json" -d "{\"count\":$count,\"token\":\"$token\"}" $host/cards/$cid -sL`
|
||||
echo ok
|
||||
echo "$author($cid) --> $guser"
|
||||
}
|
||||
|
||||
function card_ai() {
|
||||
card_env_ai
|
||||
count=$((count - 1))
|
||||
tmp=`curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$gid,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\",\"author\":\"$username\",\"count\":0}" -sL $host/cards`
|
||||
tmp=`curl -X PATCH -H "Content-Type: application/json" -d "{\"count\":$count,\"token\":\"$token\"}" $host/cards/$cid -sL`
|
||||
echo ok
|
||||
echo "$author($cid) --> $guser"
|
||||
echo "---"
|
||||
echo 'thx!'
|
||||
echo card:$ai_card
|
||||
echo cp:$ai_cp
|
||||
echo author:$ai_author
|
||||
tmp=`curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$uid,\"card\":$ai_card,\"status\":\"$ai_s\",\"cp\":$ai_cp,\"password\":\"$pass\",\"skill\":\"$ai_skill\",\"author\":\"$ai_author\",\"count\":0}" -sL $host/cards`
|
||||
}
|
||||
|
||||
function card_ai_select() {
|
||||
card_env_ai_select
|
||||
count=$((count - 1))
|
||||
tmp=`curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$gid,\"card\":$card,\"status\":\"$s\",\"cp\":$cp,\"password\":\"$pass\",\"skill\":\"$skill\",\"author\":\"$username\",\"count\":0}" -sL $host/cards`
|
||||
tmp=`curl -X PATCH -H "Content-Type: application/json" -d "{\"count\":$count,\"token\":\"$token\"}" $host/cards/$cid -sL`
|
||||
echo ok
|
||||
echo "$author($cid) --> $guser"
|
||||
echo "---"
|
||||
echo 'thx!'
|
||||
echo card:$ai_card
|
||||
echo cp:$ai_cp
|
||||
echo author:$ai_author
|
||||
tmp=`curl -X POST -H "Content-Type: application/json" -d "{\"owner\":$uid,\"card\":$ai_card,\"status\":\"$ai_s\",\"cp\":$ai_cp,\"password\":\"$pass\",\"skill\":\"$ai_skill\",\"author\":\"$ai_author\",\"count\":0}" -sL $host/cards`
|
||||
}
|
||||
|
||||
function card_status(){
|
||||
all_data=`curl -sL "$host/users?itemsPerPage=3000"`
|
||||
data=`echo $all_data|jq ".[]|select(.username == \"$username\")"`
|
||||
uid=`echo $data|jq -r .id`
|
||||
acard=`curl -sL "$host/users/$uid/card?itemsPerPage=3000"|jq ".[]|select(.author == \"$username\")|.id"`
|
||||
if [ -z "$acard" ];then
|
||||
echo no card
|
||||
exit
|
||||
fi
|
||||
echo $acard
|
||||
}
|
||||
|
||||
function test_cmd(){
|
||||
echo "test ok /gift $1"
|
||||
echo cid:$cid
|
||||
echo guser:$guser
|
||||
exit
|
||||
}
|
||||
|
||||
case $cid in
|
||||
"status")
|
||||
card_status
|
||||
;;
|
||||
"ai")
|
||||
#test_cmd ai
|
||||
card_ai
|
||||
;;
|
||||
*)
|
||||
if [ "ai" = "$guser" ];then
|
||||
#test_cmd ai_select
|
||||
card_ai_select
|
||||
else
|
||||
#test_cmd gift user
|
||||
card_gift
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
exit
|
Reference in New Issue
Block a user