Advertisement
Guest User

twitter bot code thing

a guest
Feb 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #twitter boot made by Valery
  2. #from an online tutorial
  3.  
  4. #the imports
  5. import os
  6. from markovbot import MarkovBot
  7. # Initialise a MarkovBot instance
  8.  
  9. tweetbot = MarkovBot()
  10.  
  11. #read the text file
  12. dirname = os.path.dirname(os.path.abspath('text.txt'))
  13. # Construct the path to the book
  14. book = os.path.join(dirname, 'text.txt')
  15. # Make your bot read the book!
  16. tweetbot.read(book)
  17.  
  18.  
  19. my_first_text = tweetbot.generate_text(25, seedword=['dream', 'psychoanalysis'])
  20. print("tweetbot says:")
  21. print(my_first_text)
  22.  
  23.  
  24. # ALL YOUR SECRET STUFF!
  25. # Consumer Key (API Key)
  26. cons_key ='k0ImNXT4VZjrQpcCr2wyg1M1l'
  27. # Consumer Secret (API Secret)
  28. cons_secret = 'uPRpOVf01CXVfb8cDvUAZfFX2LKftJioRQq9seyMWI6pkbcqpb'
  29. # Access Token
  30. access_token = '619802148-Ru2rdgxK3CS6Kl1UTFDYkrd5Us5QdjghyM0vPjwH'
  31. # Access Token Secret
  32. access_token_secret = 'QmRlhtZ0wYd0FhtZzySjhJHfGojXrvi7RJnjIC1E0ZeYe'
  33.  
  34. tweetbot.twitter_login(cons_key, cons_secret, access_token, access_token_secret)
  35.  
  36. targetstring = 'project'
  37. keywords = ['arduino', 'circuits', 'flowers', 'children', 'religion','raspberry','pi']
  38. prefix = None
  39. suffix = '#DoIt'
  40. maxconvdepth = None
  41.  
  42.  
  43. # Start auto-responding to tweets
  44. tweetbot.twitter_autoreply_start(targetstring, keywords=keywords, prefix=prefix, suffix=suffix, maxconvdepth=maxconvdepth)
  45.  
  46. # Use the following to stop auto-responding
  47. # (Don't do this directly after starting it, or your bot will do nothing!)
  48. #tweetbot.twitter_autoreply_stop()
  49.  
  50.  
  51.  
  52. # Start periodically tweeting
  53. tweetbot.twitter_tweeting_start(days=0, hours=0, minutes=1, keywords=None, prefix=None, suffix='#PyGaze')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement