Skip to content

Instantly share code, notes, and snippets.

@pjflanagan
Created May 13, 2020 16:04
Show Gist options
  • Save pjflanagan/86c7f856c2f2a286400a769228d8fabb to your computer and use it in GitHub Desktop.
Save pjflanagan/86c7f856c2f2a286400a769228d8fabb to your computer and use it in GitHub Desktop.
import tweepy
import requests
execfile("../TWITTER_CREDENTIALS.py")
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.secure = True
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
# If the authentication was successful, you should
# see the name of the account print out
print("NAME: " + api.me().name)
rate = api.rate_limit_status()
remaining = rate["resources"]["help"]["/help/tos"]["remaining"]
print("RATE: " + str(remaining))
tweets = api.user_timeline("alliecell")
for tweet in tweets:
#get the tweet info
text = tweet.text
favorited = tweet.favorited
retweeted = tweet.retweeted
tweet_id = tweet.id
#if it is a retweet, continue
if text[:2] == "RT":
continue
#if it has a new line command, dont print it all
if "\n" in text:
text = text[:text.index("\n")] + "..."
#format for if I have favorited it
f = "[X]" if favorited else "[ ]"
#print it
print(str(remaining) + " " + f + " " + text)
#check the remaining
if remaining <= 3:
break
#favorite the tweet if I havent already
if(not favorited and not retweeted):
api.create_favorite(tweet_id)
remaining -= 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment