Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. MESSAGE_SUBJECT = r"anything"
  2. MESSAGE_BODY = r"https://www.youtube.com/"
  3. DISALLOW_KEYWORD = r"anything".lower()
  4. ALLOW_KEYWORD = r"anything".lower()
  5. SUBREDDIT = "anything"
  6. import praw, prawcore, time
  7. reddit = praw.Reddit(
  8. client_id='x',
  9. client_secret='x',
  10. user_agent='MacOSv10:idontknowwhattoputhere.pleasedonthurtme:v1.1.0 (by /u/billy_boi32)',
  11. username='billy_boi32',
  12. password=r"x"
  13. )
  14. def retry(f):
  15. def temp(*args):
  16. failure=True
  17. while failure:
  18. try:
  19. f(*args)
  20. except:
  21. print("error, retrying in 3 seconds")
  22. time.sleep(3)
  23. else:
  24. failure=False
  25. return temp
  26. while True:
  27. try:
  28. for post in reddit.subreddit(SUBREDDIT).stream.submissions(skip_existing=True):
  29. if ALLOW_KEYWORD in post.title.lower() and DISALLOW_KEYWORD not in post.title.lower():
  30. retry(post.author.message)(MESSAGE_SUBJECT, MESSAGE_BODY)
  31. except:
  32. time.sleep("error, retrying in 10 seconds")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement