def ratio_check(self): if self.follows >= max_follows: time.sleep(86400) if me.friends_count >= 2000: ratio = me.friends_count + (me.followers_count / 10) if me.friends_count >= ratio: debug.action( 'Following to follower ratio is off! Starting the unfollow loop...' ) unfollow_loop()
def run(self): while True: try: followers = api.followers_ids(me.screen_name) friends = api.friends_ids(me.screen_name) if me.friends_count / me.followers_count == 3: debug.action('Following to follower ratio is off! Starting the unfollow loop...') unfollow_loop() for follower in followers: if not follower in friends: api.create_friendship(follower) api.send_direct_message(screen_name=follower, text='Thanks for following our Twitter. Be sure to share us with your friends & keep up with the latest sports news!') debug.alert('Followed back a follower!') time.sleep(30) except tweepy.TweepError as ex: debug.error('Error occured in the follow loop!', ex) finally: time.sleep(60*15)
def loop_unfollow(self): try: followers = self.api.followers_ids(self.me.screen_name) friends = self.api.friends_ids(self.me.screen_name) non_friends = [ friend for friend in friends if friend not in followers ] non_friends.reverse() debug.action('Unfollowing {0} unsupporting friends...'.format( len(non_friends))) for friend in non_friends: self.api.destroy_friendship(friend) self.unfollows += 1 debug.alert('Unfollowed an unsupporting friend!') if self.unfollows == self.max_unfollows: break else: time.sleep(60 * functions.random_int(10, 15)) except tweepy.TweepError as ex: debug.error('Error occured in the unfollow loop!', ex) finally: self.unfollows = 0
def loop_follow(self): while True: try: followers = api.followers_ids(me.screen_name) friends = api.friends_ids(me.screen_name) non_friends = [ friend for friend in followers if friend not in friends ] debug.action('Following back {0} supporters...'.format( len(non_friends))) for follower in non_friends: api.create_friendship(follower) self.follows += 1 debug.alert('Followed back a follower!') if self.follows >= self.max_follows: break if self.send_message: api.send_direct_message(screen_name=follower, text=self.message) time.sleep(30) except tweepy.TweepError as ex: debug.error('Error occured in the follow loop!', ex) finally: time.sleep(60 * 15)
def stats(): debug.action('SceenName\t: %s' % me.screen_name) debug.action('Registered\t: %s' % me.created_at) debug.action('Favorites\t: %s' % me.favourites_count) debug.action('Following\t: %s' % me.friends_count) debug.action('Followers\t: %s' % me.followers_count) debug.action('Tweets\t\t: %s' % me.statuses_count)
def stats(self): debug.action('SceenName : ' + self.me.screen_name) debug.action('Registered : ' + self.me.created_at) debug.action('Favorites : ' + self.me.favourites_count) debug.action('Following : ' + self.me.friends_count) debug.action('Followers : ' + self.me.followers_count) debug.action('Tweets : ' + self.me.statuses_count)