Ejemplo n.º 1
0
def now(amount):

    print("...function follow called. Let's try to follow some people.")
     
    my_api = api.make_api()
     
    #Iterate through amount posts with a certain hashtag, may hit API throttling eventually
    for tweet in tweepy.Cursor(my_api.search, q = definitions.follow_hashtag, count = 10, include_entities = True).items(amount):
	    
	    userid = tweet.user.id
	    
	    if userid != definitions.my_user_id: # latter one from secrets
	    
	        try: # some users may have blocked you, so try and else continue
	    
	            my_api.create_friendship(userid)
	            print("userid {} followed".format(userid))
	            print("Waiting a bit")
	    
	            #time.sleep(definitions.interval_between_follows) #Tweet every 15 minutes
	    
	        except:
	    
	            print("Could not follow {}".format(userid))
	    
	            continue
Ejemplo n.º 2
0
def unfollow_non_friends(amount):

    print("function unfollow_non_friends called")
    my_api = api.make_api()

    # make a list of followers
    followers = my_api.followers_ids(my_user_id)
    print("...found {} follower".format(len(followers)))
    
    # make a list if following
    following = my_api.friends_ids(my_user_id)
    print("...found {} following".format(len(following)))
       
    # makes a new list of users who don't follow you back.
    non_mutuals = list(set(following) - set(followers))
    print("...found {} non_mutuals / non_friends".format(len(non_mutuals)))
    
    # unfollow our non_friends
    if len(non_mutuals) > amount:
        for f in non_mutuals[0:amount]:
            try:
                # unfollows non follower.
                my_api.destroy_friendship(f)
                print('...Unfollowed user {}. Waiting a bit.'.format(f))
                #time.sleep(10)
            except:
                print("...could not unfollow user {}".format(f))
                continue
    else:
        print("Too few non_friends to unfollow now. Doing nothing for the moment.")
        pass
Ejemplo n.º 3
0
def get_last_tweet_rank():

    my_api = api.make_api()

    # get the last tweet
    tweet = my_api.user_timeline(id=definitions.my_user_id, count=1)[0].text

    # use a regex to get the first number from the string
    plek = re.search(r'\d+', tweet).group()

    # plek = tweet.text[8:12] #old way to get first number

    return plek
Ejemplo n.º 4
0
def post(message):
    print("...function post_tweet called")

    #get_image(youtube_link)
    #filename = "temp_img.jpg"

    # create the api
    my_api = api.make_api()

    # send the tweet with the image and a random message
    my_api.update_status(status=message)
    #my_api.update_with_media(filename, status=message)
    print("tweeted!")
Ejemplo n.º 5
0
def post():
    print("...function post_tweet called")
    
    # create the api
    my_api = api.make_api()

    #define the file name    
    filename = "temp_image.jpg"
    
    # define the message
    message = get_message()
                
    # send the tweet with the image and a random message
    my_api.update_with_media(filename, status = message + message_hashtags)
    print("tweeted!")
    print("...")