Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import praw
  2. import config
  3. import time
  4.  
  5. def bot_login():
  6. print "Loggin in..."
  7. r = praw.Reddit(username = config.username,
  8. password = config.password,
  9. client_id = config.client_id,
  10. client_secret = config.client_secret,
  11. user_agent = "python")
  12. print "Logged in!"
  13.  
  14. return r
  15.  
  16. def run_bot(r):
  17. global theCount
  18. print "Obtaining 25 comments..."
  19. for comment in r.subreddit('all').comments(limit=300):
  20. theCount = theCount+1
  21. if theCount>9999:
  22. print comment.id
  23. f = open("history.txt", "r")
  24. fRead = f.read()
  25. f.close()
  26. if comment.id not in fRead:
  27. f = open("history.txt", "a")
  28. f.write(comment.id)
  29. f.close
  30. try:
  31. comment.reply("Or you could stop clogging up reddit with shitty posts")
  32. print "Replied to comment " + comment.id
  33. theCount = 0;
  34. except:
  35. print "Something went wrong!"
  36. else:
  37. print "comment ignored! Remeber to clear the logs."
  38.  
  39. print "Sleeping for 2 seconds..."
  40. #Sleep for 10 seconds...
  41. time.sleep(5)
  42.  
  43. while True:
  44. try:
  45. theCount = 0
  46. r = bot_login()
  47. while True:
  48. run_bot(r)
  49. except:
  50. print "Error! Trying Again."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement