GapajYT

Untitled

Mar 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import praw
  2. import os
  3. import time
  4. import datetime
  5. from multiprocessing import Process
  6.  
  7. SUBREDDIT_NAME = 'all'
  8. KEYWORDS = [snip]
  9. RESPONSE = [snip]
  10. BANNED_USERS = [snip]
  11.  
  12. USERNAME = [redacted]
  13. PASSWORD = [redacted]
  14. CLIENT_ID = [redacted]
  15. CLIENT_SECRET = [redacted]
  16.  
  17. USER_AGENT = 'script:reply to keywords in comments:v0.2:written by /u/doug89'
  18.  
  19.  
  20. print("Authenticating...")
  21. reddit = praw.Reddit(
  22. client_id=CLIENT_ID,
  23. client_secret=CLIENT_SECRET,
  24. password=PASSWORD,
  25. user_agent=USER_AGENT,
  26. username=USERNAME)
  27. print("Authenticaed as {}".format(reddit.user.me()))
  28.  
  29. comments = reddit.user.me().comments.new(limit=None)
  30.  
  31. def loop():
  32. for comment in reddit.subreddit(SUBREDDIT_NAME).stream.comments(pause_after=1):
  33. if comment is None:
  34. break
  35. if comment.saved:
  36. continue
  37. has_keyword = any(k.lower() in comment.body.lower() for k in KEYWORDS)
  38. not_self = comment.author != reddit.user.me()
  39. not_banned = comment.author != BANNED_USERS
  40. if has_keyword and not_self and not_banned:
  41. try:
  42. comment.save()
  43. reply = comment.reply(RESPONSE)
  44. print(datetime.datetime.now())
  45. except:
  46. pass
  47. for comment in comments:
  48. if comment.score < -5:
  49. comment.delete()
  50.  
  51. x = 1
  52. while True:
  53. loop()
Add Comment
Please, Sign In to add comment