-
Notifications
You must be signed in to change notification settings - Fork 7
/
handle_follow.sh
executable file
·52 lines (42 loc) · 1.12 KB
/
handle_follow.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
work_dir="$(pwd)"
tools_dir="$(cd "$(dirname "$0")" && pwd)"
source "$tools_dir/common.sh"
logfile="$log_dir/handle_follow.log"
lock_key=''
while unlock "$lock_key" && read -r event
do
follower="$(echo "$event" | jq -r .source.screen_name)"
lock_key="follow.$follower"
try_lock_until_success "$lock_key"
log '=============================================================='
log "Followed by $follower"
if [ "$follower" = "$MY_SCREEN_NAME" ]
then
log " => ignored, because this is my activity"
continue
fi
user="$(echo "$event" | jq -c .source)"
if echo "$user" | is_protected_user
then
log " => protected user should not be followed to avoid privacy issues"
continue
fi
if echo "$user" | is_spam_like_user
then
log " => spam like user should not be followed"
continue
fi
if is_true "$FOLLOW_ON_FOLLOWED"
then
log " => follow back $follower"
result="$("$tweet_sh" follow $follower)"
if [ $? = 0 ]
then
log ' => successfully followed'
else
log " => failed to follow $follower"
log " result: $result"
fi
fi
done