Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import praw
  2. import config
  3. import time
  4.  
  5. r = praw.Reddit(client_id=config.client_id, client_secret=config.client_secret, user_agent='NoThanksBot 1.0 by /u/NoThanksBot', username=config.username, password=config.password)
  6.  
  7. words_to_match = ['want something?']
  8. cache = []
  9.  
  10. def run_bot():
  11. subreddit = r.subreddit("test")
  12. print("Hacking subreddit")
  13. print("Scanning comments")
  14. posts = subreddit.new(limit = 5)
  15. comments = subreddit.comments(limit=20)
  16. for comment in comments:
  17. comment_text = comment.body.lower()
  18. isMatch = any(string in comment_text for string in words_to_match)
  19. if comment.id not in cache and isMatch:
  20. print("Match found! Comment ID: " +comment.id)
  21. comment.reply('No thanks.')
  22. print("User anihilated.")
  23. cache.append(comment.id)
  24. print("Anihilation finished. Restarting program.")
  25.  
  26. count = 0
  27. while count < 50:
  28. run_bot()
  29. count += 1
  30. time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement