summary refs log tree commit diff stats
path: root/father.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-08-06 16:16:10 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-08-06 16:16:10 -0400
commitd16ccf85c75f34c142736b6e1b7dc491898a1932 (patch)
tree646346ec617dc1b4bd7397f1029ca4f9112537f0 /father.cpp
parentf605bf346904c18b3ba69c8cf2a624c5905f8cf5 (diff)
downloadfather-d16ccf85c75f34c142736b6e1b7dc491898a1932.tar.gz
father-d16ccf85c75f34c142736b6e1b7dc491898a1932.tar.bz2
father-d16ccf85c75f34c142736b6e1b7dc491898a1932.zip
Ignore locked accounts when syncing followers
Previously, if a locked account was following the bot, it would give up syncing friends after receiving an error from Twitter if it had previously attempted to follow that account and the account hadn't accepted the request yet. Now, the bot does not attempt to follow locked accounts.

refs hatkirby/snitch#1
Diffstat (limited to 'father.cpp')
-rw-r--r--father.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/father.cpp b/father.cpp index 4ff4a3c..d95f506 100644 --- a/father.cpp +++ b/father.cpp
@@ -80,22 +80,28 @@ int main(int argc, char** argv)
80 std::end(followers), 80 std::end(followers),
81 std::back_inserter(oldFriends)); 81 std::back_inserter(oldFriends));
82 82
83 std::list<twitter::user_id> newFollowers; 83 std::set<twitter::user_id> newFollowers;
84 std::set_difference( 84 std::set_difference(
85 std::begin(followers), 85 std::begin(followers),
86 std::end(followers), 86 std::end(followers),
87 std::begin(friends), 87 std::begin(friends),
88 std::end(friends), 88 std::end(friends),
89 std::back_inserter(newFollowers)); 89 std::inserter(newFollowers, std::begin(newFollowers)));
90 90
91 for (twitter::user_id f : oldFriends) 91 for (twitter::user_id f : oldFriends)
92 { 92 {
93 client.unfollow(f); 93 client.unfollow(f);
94 } 94 }
95 95
96 for (twitter::user_id f : newFollowers) 96 std::list<twitter::user> newFollowerObjs =
97 client.hydrateUsers(std::move(newFollowers));
98
99 for (twitter::user f : newFollowerObjs)
97 { 100 {
98 client.follow(f); 101 if (!f.isProtected())
102 {
103 client.follow(f);
104 }
99 } 105 }
100 } catch (const twitter::twitter_error& error) 106 } catch (const twitter::twitter_error& error)
101 { 107 {