Skip to content

Instantly share code, notes, and snippets.

@rocapp
Last active January 16, 2017 15:51
Show Gist options
  • Save rocapp/74ea88a440040f4d03b8385c30db07cc to your computer and use it in GitHub Desktop.
Save rocapp/74ea88a440040f4d03b8385c30db07cc to your computer and use it in GitHub Desktop.
def do_tweet(auth, tttw=10):
api = API(auth) # connect to Twitter using my authorization info
words = get_words('tweets.txt') # Get words from general tweets
words.extend(get_haikus('haiku.txt')) # Get previously written but un-tweeted haikus
words.extend(get_best('best.txt')) # Get list of "best" tweets
words.extend(get_words('search.txt')) # Get list of specifically searched terms
sdict = make_sdict(words) # Make a dictionary that maps words to their number of syllables
# Make a list of haikus and tweet them every 15 minutes
haik = list()
j = 0
while j < tttw:
h = haiku(sdict).lower()
haik.append(h)
print(h)
api.update_status(h)
print("Tweeted! at %s" % time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()))
time.sleep(900)
j+=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment