From 6e624b931ca55a02e51f0ee65b379a567696ae06 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 6 Aug 2018 16:29:54 -0400 Subject: Ignore locked accounts when syncing followers This bot basically just shouldn't follow locked accounts, there's no reason for it to. --- toldya.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'toldya.cpp') diff --git a/toldya.cpp b/toldya.cpp index 55f00a8..0910945 100644 --- a/toldya.cpp +++ b/toldya.cpp @@ -102,13 +102,13 @@ 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))); std::set oldFriendsSet; for (twitter::user_id f : oldFriends) @@ -125,15 +125,21 @@ int main(int argc, char** argv) } } - for (twitter::user_id f : newFollowers) + std::list newFollowerObjs = + client.hydrateUsers(std::move(newFollowers)); + + for (const twitter::user& f : newFollowerObjs) { - try - { - client.follow(f); - } catch (const twitter::twitter_error& error) + if (!f.isProtected()) { - std::cout << "Twitter error while following: " << error.what() - << std::endl; + try + { + client.follow(f); + } catch (const twitter::twitter_error& error) + { + std::cout << "Twitter error while following: " << error.what() + << std::endl; + } } } -- cgit 1.4.1