Last active
December 13, 2021 09:04
-
-
Save eggplants/bae322667731010afba0a0eb990478dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
if ! command -v twurl jq &>/dev/null; then | |
echo "install twurl, jq" | |
exit 1 | |
elif ! [ -f ./.twurlrc ]; then | |
echo "twurl authorize" >&2 | |
exit 1 | |
fi | |
you=egpl0 | |
list_id=1095823330366509056 | |
twurl "/1.1/followers/ids.json?user_name=${you}&count=5000" | | |
jq -r '.ids|join("\n")' > followed | |
twurl "/1.1/lists/members.json?list_id=${list_id}&count=5000" | | |
jq -r '.users[].id' > member | |
sort target followed followed | uniq -u > target | |
t="$(wc -l <target)" | |
[ "$t" -gt 400 ] && echo "一日400フォローまでなので明日もよろしく" | |
c=1 | |
head -400 target | while read i; do | |
echo -n "[${c}/${t}: ${i}]" | |
if twurl "/1.1/friendships/create.json" -d "user_id=${i}" | | |
grep -q '"errors"'; then | |
echo "=>NG" | |
else | |
echo "=>OK" | |
fi | |
sleep 3s | |
((c++)) | |
done | |
rm -i followed member target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment