Skip to content

Commit 91a7374

Browse files
author
Randy Olson
committed
Merge pull request #52 from kyranb/master
Added the ability to unfollow all followers.
2 parents 78270ce + 65dc75c commit 91a7374

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,19 @@ By default, the bot looks up the 100 most recent tweets. You can change this num
167167
my_bot = TwitterBot()
168168
my_bot.auto_unfollow_nonfollowers()
169169

170+
If there are certain users that you would like to not unfollow, add their user id to the USERS_KEEP_FOLLOWING list.
171+
170172
You will need to manually edit the code if you want to add special users that you will keep following even if they don't follow you back.
171173

174+
####Automatically unfollow all users.
175+
176+
from TwitterFollowBot import TwitterBot
177+
178+
my_bot = TwitterBot()
179+
my_bot.auto_unfollow_all_followers()
180+
181+
182+
172183
####Automatically mute all users that you have followed
173184

174185
from TwitterFollowBot import TwitterBot

TwitterFollowBot/__init__.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,23 @@ def auto_unfollow_nonfollowers(self,count=None):
398398

399399
for user_id in not_following_back:
400400
if user_id not in self.BOT_CONFIG["USERS_KEEP_FOLLOWING"]:
401-
401+
402402
self.wait_on_action()
403-
403+
404+
self.TWITTER_CONNECTION.friendships.destroy(user_id=user_id)
405+
print("Unfollowed %d" % (user_id), file=sys.stdout)
406+
407+
def auto_unfollow_all_followers(self,count=None):
408+
"""
409+
Unfollows everyone that you are following(except those who you have specified not to)
410+
"""
411+
following = self.get_follows_list()
412+
413+
for user_id in following:
414+
if user_id not in self.BOT_CONFIG["USERS_KEEP_FOLLOWING"]:
415+
416+
self.wait_on_action()
417+
404418
self.TWITTER_CONNECTION.friendships.destroy(user_id=user_id)
405419
print("Unfollowed %d" % (user_id), file=sys.stdout)
406420

0 commit comments

Comments
 (0)