Browse Source

first

master
syui 2 years ago
commit
787db33164
No known key found for this signature in database GPG Key ID: ED2A0F5F1DA25512
  1. 1
      .gitignore
  2. 4
      config.example.json
  3. 12
      follow.zsh
  4. 1
      readme.md
  5. 52
      scpt/github.zsh
  6. 52
      scpt/qiita.zsh

1
.gitignore

@ -0,0 +1 @@
config.json

4
config.example.json

@ -0,0 +1,4 @@
{
"github_token":"",
"qiita_token":""
}

12
follow.zsh

@ -0,0 +1,12 @@
#!/bin/zsh
d=${0:a:h}
case $1 in
github|g)
$d/scpt/github.zsh
;;
qiita|q)
$d/scpt/qiita.zsh
;;
esac

1
readme.md

@ -0,0 +1 @@
follower = following

52
scpt/github.zsh

@ -0,0 +1,52 @@
#!/bin/zsh
#https://developer.github.com/v3/users/followers/
#/users/:user/following
#/users/:user/followers
j=${0:a:h:h}/config.json
token=`cat $j|jq -r ".github_token"`
max=30
n=$max i=1
while [ $n -eq $max ]
do
fwers=`curl -sL -u syui:$token "https://api.github.com/users/syui/followers?page=$i" | jq -r ".[].html_url"|cut -d / -f 4`
n=`echo $fwers|wc -l`
fwer="${fwers}\n${fwer}"
i=$(( i + 1 ));
done
n=$max i=1
while [ $n -eq $max ]
do
fings=`curl -sL -u syui:$token "https://api.github.com/users/syui/following?page=$i" | jq -r ".[].html_url"|cut -d / -f 4`
n=`echo $fings|wc -l`
fing="${fings}\n${fing}"
i=$(( i + 1 ));
done
a=`echo "$fwer"|sed '/^$/d'|wc -l`
b=`echo "$fing"|sed '/^$/d'|wc -l`
if [ $a -ge $b ];then
echo ok followrs following
echo $a $b
exit
else
echo no followrs following
echo $a $b
fi
n=`echo "${fwer}\n${fing}"|sed '/^$/d'|sort| uniq -u |wc -l`
t=`echo "${fwer}\n${fing}"|sed '/^$/d'|sort|uniq -u`
echo $n
echo $t
for ((i=1;i<=$n;i++))
do
user=`echo "$t"|awk "NR==$i"`
echo $user
echo curl -i -X DELETE -H "Authorization: token ${token}" https://api.github.com/users/following/$user
echo "enter"
read
curl -i -sL -X DELETE -H "Authorization: token ${token}" https://api.github.com/user/following/$user
done

52
scpt/qiita.zsh

@ -0,0 +1,52 @@
#!/bin/zsh
#https://qiita.com/api/v2/docs
#/api/v2/users/:user_id/followers
#/api/v2/users/:user_id/followees
j=${0:a:h:h}/config.json
token=`cat $j|jq -r ".qiita_token"`
max=20
n=$max i=1
while [ $n -eq $max ]
do
fwers=`curl -sL -X GET "https://qiita.com/api/v2/users/syui/followers?page=${i}" -H "Authorization: Bearer $token" -H "Content-Type: application/json" | jq -r ".[].id"`
n=`echo $fwers|wc -l`
fwer="${fwers}\n${fwer}"
i=$(( i + 1 ));
done
n=$max i=1
while [ $n -eq $max ]
do
fings=`curl -sL -X GET "https://qiita.com/api/v2/users/syui/followees?page=${i}" -H "Authorization: Bearer $token" -H "Content-Type: application/json" | jq -r ".[].id"`
n=`echo $fings|wc -l`
fing="${fings}\n${fing}"
i=$(( i + 1 ));
done
a=`echo "$fwer"|sed '/^$/d'|wc -l`
b=`echo "$fing"|sed '/^$/d'|wc -l`
if [ $a -ge $b ];then
echo ok followrs following
echo $a $b
exit
else
echo no followrs following
echo $a $b
fi
n=`echo "${fwer}\n${fing}"|sed '/^$/d'|sort| uniq -u |wc -l`
t=`echo "${fwer}\n${fing}"|sed '/^$/d'|sort|uniq -u`
echo $n
echo $t
for ((i=1;i<=$n;i++))
do
user=`echo "$t"|awk "NR==$i"`
echo $user
echo curl -i -sL -X DELETE "https://qiita.com/api/v2/users/$user/following" -H "Authorization: Bearer $token" -H "Content-Type: application/json"
echo "enter"
read
curl -i -sL -X DELETE "https://qiita.com/api/v2/users/$user/following" -H "Authorization: Bearer $token" -H "Content-Type: application/json"
done
Loading…
Cancel
Save