def check_if_follows(): api = _get_api() hits = utils.get_hits_left(api.rate_limit_status(), 'followers', '/followers/list') print hits if hits < 1: return for user in tweepy.Cursor(api.followers, screen_name="CigiBot").items(): print user.screen_name
def auto_follow(): api = _get_api() hits = utils.get_hits_left(api.rate_limit_status(), 'followers', '/followers/list') print "auto_follow: We have %s hits left" % (hits,) if hits < 1: return for follower in tweepy.Cursor(api.followers).items(): follower.follow()
def auto_follow(): api = _get_api() hits = utils.get_hits_left(api.rate_limit_status(), 'followers', '/followers/list') print "auto_follow: We have %s hits left" % (hits,) if hits < 1: return saved_followers = get_saved_followers() for follower in tweepy.Cursor(api.followers).items(): if (follower.screen_name,) not in saved_followers: follower.follow()
def refresh_followers(): api = _get_api() cur = _get_cursor() hits = utils.get_hits_left(api.rate_limit_status(), 'followers', '/followers/list') print "refresh_followers: We have %s hits left" % (hits,) if hits < 1: return try: for user in tweepy.Cursor(api.followers, screen_name="CigiBot").items(): cur.execute("""INSERT INTO FOLLOWER (id,screen_name) SELECT %s, %s WHERE NOT EXISTS (SELECT id FROM FOLLOWER WHERE id = %s)""", (str(user.id), user.screen_name, str(user.id))) conn.commit() except TweepError as err: raise refresh_followers.retry(countdown=60 * 3, exc=err)
def fetchdms(): api = _get_api() hits = utils.get_hits_left(api.rate_limit_status(), 'direct_messages', '/direct_messages') if hits < 1: return messages = None sinceid = _get_sinceid('dm_sinceid') try: messages = api.direct_messages(since_id=sinceid) except TweepError as err: print "Failed to fetch DMs", err return if len(messages) is not 0: dmhandlers.DmCommandHandler(messages) _set_sinceid('dm_sinceid', messages[0].id) destroy_dms.delay(messages) else: if DEBUG: print "No new DMs yet! Hits left %s" % (hits,)