Advertisement
Guest User

Untitled

a guest
Mar 8th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. print("Authenticating...")
  2. reddit = praw.Reddit(
  3. client_id=CLIENT_ID,
  4. client_secret=CLIENT_SECRET,
  5. password=PASSWORD,
  6. user_agent=USER_AGENT,
  7. username=USERNAME)
  8. print("Authenticaed as {}".format(reddit.user.me()))
  9.  
  10. def get_list_of_banned_subreddits():
  11. p = re.compile(r"(?<=You have been banned from participating in )(.*)(?=. You can still view and subscribe)")
  12. bot_user = reddit_client.redditor('RickrollingIsDead')
  13. messages = reddit_client.inbox.messages()
  14. return [p.search(m.body).group(0) for m in messages if p.search(m.body)]
  15.  
  16. COMMENTS = reddit.user.me().comments.new(limit=None)
  17. print("Stream has been started at", datetime.datetime.now())
  18. x = 1
  19. while True:
  20. for comment in reddit.subreddit(SUBREDDIT_NAME).stream.comments():
  21. if comment.saved:
  22. continue
  23. reddit.submission(test_post).delete()
  24. has_keyword = any(k.lower() in comment.body.lower() for k in KEYWORDS)
  25. not_self = comment.author != reddit.user.me()
  26. if has_keyword and not_self and not_banned:
  27. try:
  28. comment.save()
  29. reply = comment.reply(RESPONSE)
  30. print(datetime.datetime.now())
  31. time.sleep(660)
  32. except Exception as e:
  33. if e.error_type == 'SUBREDDIT_NOTALLOWED':
  34. print('Banned from some_sub')
  35. else:
  36. print(e)
  37. else:
  38.  
  39. for comment in comments:
  40. if comment.score < -5:
  41. comment.delete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement