Advertisement
Guest User

Untitled

a guest
Mar 8th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 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.  
  11. USERNAME = [SNIP]
  12. PASSWORD = [SNIP]
  13. CLIENT_ID = [SNIP]
  14. CLIENT_SECRET = [SNIP]
  15.  
  16. USER_AGENT = 'script:reply to keywords in comments:v0.2:written by /u/doug89'
  17.  
  18. print("Authenticating...")
  19. reddit = praw.Reddit(
  20. client_id=CLIENT_ID,
  21. client_secret=CLIENT_SECRET,
  22. password=PASSWORD,
  23. user_agent=USER_AGENT,
  24. username=USERNAME)
  25. print("Authenticaed as {}".format(reddit.user.me()))
  26.  
  27. def get_list_of_banned_subreddits():
  28. p = re.compile(r"(?<=You have been banned from participating in )(.*)(?=. You can still view and subscribe)")
  29. bot_user = reddit_client.redditor('RickrollingIsDead')
  30. messages = reddit_client.inbox.messages()
  31. return [p.search(m.body).group(0) for m in messages if p.search(m.body)]
  32.  
  33. COMMENTS = reddit.user.me().comments.new(limit=None)
  34. print("Stream has been started at", datetime.datetime.now())
  35. x = 1
  36. while True:
  37. for comment in reddit.subreddit(SUBREDDIT_NAME).stream.comments():
  38. if comment.saved:
  39. continue
  40. reddit.submission(test_post).delete()
  41. has_keyword = any(k.lower() in comment.body.lower() for k in KEYWORDS)
  42. not_self = comment.author != reddit.user.me()
  43. if has_keyword and not_self:
  44. comment.save()
  45. reply = comment.reply(RESPONSE)
  46. print(datetime.datetime.now())
  47. time.sleep(660)
  48.  
  49. for comment in comments:
  50. if comment.score < -5:
  51. comment.delete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement