Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import praw
  2.  
  3. SUBREDDIT_NAME = 'registertovotebot', 'politics', 'bluemidterm2018'
  4. KEYWORDS = ['register', '!register', 'bluemidterm2018']
  5. RESPONSE = 'Please visit [Vote.org](http://www.Vote.org) to determine if youre reigstered to vote and get registered'
  6.  
  7. USERNAME = ''
  8. PASSWORD = ''
  9. CLIENT_ID = ''
  10. CLIENT_SECRET = ''
  11.  
  12. USER_AGENT = 'script:reply to keywords in comments:v0.2:written by /u/ask_how_high_i_am'
  13.  
  14. print("Authenticating...")
  15. reddit = praw.Reddit(
  16. client_id=CLIENT_ID,
  17. client_secret=CLIENT_SECRET,
  18. password=PASSWORD,
  19. user_agent=USER_AGENT,
  20. username=USERNAME)
  21. print("Authenticaed as {}".format(reddit.user.me()))
  22.  
  23. print('Starting comment stream...')
  24. for comment in reddit.subreddit(SUBREDDIT_NAME).stream.comments():
  25. if comment.saved:
  26. continue
  27. has_keyword = any(k.lower() in comment.body.lower() for k in KEYWORDS)
  28. not_self = comment.author != reddit.user.me()
  29. if has_keyword and not_self:
  30. comment.save()
  31. reply = comment.reply(RESPONSE)
  32. print('http://reddit.com{}'.format(reply.permalink()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement