Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. #!/usr/bin/python
  2. import praw
  3. import random
  4. from credentials import *
  5.  
  6. r = praw.Reddit(user_agent = USER_AGENT)
  7. r.login(REDDIT_USERNAME, REDDIT_PASSWORD)
  8.  
  9. subreddits = r.get_subreddit("all")
  10. targetsub = r.get_subreddit("secretsubreddit")
  11. title = "[Leak detected] {0} on {1}. {2} protocol in effect."
  12. protocol = ["CO2", "Water", "Dry", "Foam"]
  13. rall = praw.helpers.comment_stream(r, subreddits, limit=None)
  14.  
  15. while True:
  16.  
  17.     try:
  18.  
  19.         for i in rall:
  20.  
  21.             if "r/secretsubreddit" in i.body.lower():
  22.  
  23.                 author = "/r/"+str(i.author)
  24.                 sub = "/r/"+str(i.subreddit)
  25.                 try:
  26.                     targetsub.submit(title.format(author, sub, random.choice(protocol)), str(i.permalink))
  27.  
  28.                 except Exception as e:
  29.                     log = "i couldnt post the one i saw on r/all to the sub! "+str(e)
  30.                     with open("errorlog.txt", "a") as f:
  31.                         f.writelines(log)
  32.  
  33.     except Exception as e:
  34.         log = str(e)+"\n"
  35.         with open("errorlog.txt", "a") as f:
  36.             f.writelines(log)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement