1
0
api/tmp/card_limit_all.zsh

31 lines
869 B
Bash
Raw Normal View History

2023-04-28 09:19:08 +00:00
#!/bin/zsh
case $OSTYPE in
darwin*)
alias date="/opt/homebrew/bin/gdate"
;;
esac
host=https://api.syui.ai
token=`cat ~/.config/atr/api_card.json|jq -r .token`
host_users="$host/users?itemsPerPage=2550"
updated_at_n=`date --iso-8601=seconds -d '1 days ago'`
data=`curl -sL "$host_users"|jq .`
nd=`date +"%Y%m%d"`
n=`echo $data|jq length`
n=$((n - 1))
2023-04-28 14:34:59 +00:00
if [ -n "$1" ];then
id=$1
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\",\"token\":\"$token\"}" -s $host/users/$id
exit
fi
2023-04-28 09:19:08 +00:00
for ((i=0;i<=$n;i++))
do
name=`echo $data|jq ".[$i]"|jq -r .username`
id=`echo $data|jq ".[$i]"|jq -r .id`
echo "{\"updated_at\":\"$updated_at_n\"} -s $host/users/$id"
curl -X PATCH -H "Content-Type: application/json" -d "{\"next\":\"$nd\", \"updated_at\":\"$updated_at_n\",\"token\":\"$token\"}" -s $host/users/$id
done