Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import praw
- import random
- from credentials import *
- r = praw.Reddit(user_agent = USER_AGENT)
- r.login(REDDIT_USERNAME, REDDIT_PASSWORD)
- subreddits = r.get_subreddit("all")
- targetsub = r.get_subreddit("secretsubreddit")
- title = "[Leak detected] {0} on {1}. {2} protocol in effect."
- protocol = ["CO2", "Water", "Dry", "Foam"]
- rall = praw.helpers.comment_stream(r, subreddits, limit=None)
- while True:
- try:
- for i in rall:
- if "r/secretsubreddit" in i.body.lower():
- author = "/r/"+str(i.author)
- sub = "/r/"+str(i.subreddit)
- try:
- targetsub.submit(title.format(author, sub, random.choice(protocol)), str(i.permalink))
- except Exception as e:
- log = "i couldnt post the one i saw on r/all to the sub! "+str(e)
- with open("errorlog.txt", "a") as f:
- f.writelines(log)
- except Exception as e:
- log = str(e)+"\n"
- with open("errorlog.txt", "a") as f:
- f.writelines(log)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement