BnEc

Markovify Twitter Reply Bot

Mar 15th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import tweepy
  3. import markovify
  4. from twitter_credentials import ACCESS_TOKEN, ACCESS_TOKEN_SECRET, CONSUMER_SECRET, CONSUMER_KEY
  5.  
  6. auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
  7. auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
  8. api = tweepy.API(auth)
  9.  
  10. with open("corpus.txt") as corpus:
  11.     corpus_lines = corpus.read()
  12. text_model = markovify.Text(corpus_lines)
  13. message = text_model.make_short_sentence(140)
  14. twt = api.search(q="#Ancient", since_id=3600)
  15.  
  16. for s in twt:
  17.     sn = s.user.screen_name
  18.     m = message, (sn)
  19.     s = api.update_status(m, s.id)
Advertisement
Add Comment
Please, Sign In to add comment