From d16ccf85c75f34c142736b6e1b7dc491898a1932 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 6 Aug 2018 16:16:10 -0400 Subject: 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 --- father.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'father.cpp') 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) std::end(followers), std::back_inserter(oldFriends)); - std::list newFollowers; + std::set newFollowers; std::set_difference( std::begin(followers), std::end(followers), std::begin(friends), std::end(friends), - std::back_inserter(newFollowers)); + std::inserter(newFollowers, std::begin(newFollowers))); for (twitter::user_id f : oldFriends) { client.unfollow(f); } - for (twitter::user_id f : newFollowers) + std::list newFollowerObjs = + client.hydrateUsers(std::move(newFollowers)); + + for (twitter::user f : newFollowerObjs) { - client.follow(f); + if (!f.isProtected()) + { + client.follow(f); + } } } catch (const twitter::twitter_error& error) { -- cgit 1.4.1