Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import time
- import os
- os.environ['TZ'] = 'UTC'
- time.tzset()
- def login():
- # You'll need to use your own login credentials
- r = login()
- subreddit = r.get_subreddit('bitcoin') # needs to be subreddits that you moderate, or that doesn't temporarily hide vote scores.
- timeframeNewest = (60*0)
- timeframeOldest = (60*3) # release comments older than 3 minutes
- commentIDs_downvoted = []
- commentIDs_upvoted = []
- targeted_downvotes = []
- targeted_upvotes = []
- preprocessed = []
- # ignore comments made before script was started
- new_comments = subreddit.get_comments(limit=10)
- for comment in new_comments:
- preprocessed.append(comment.id)
- def get_comments(subreddit):
- new_comments = subreddit.get_comments(limit=10) # increase this if the sub gets more than 10 comments in 3 minutes
- for comment in new_comments:
- if comment.id not in commentIDs_downvoted and comment.id not in commentIDs_upvoted and comment.id not in preprocessed:
- now = int(time.time())
- comment_score = comment.ups - comment.downs
- if (now - timeframeOldest) < comment.created_utc < (now - timeframeNewest) and comment_score < 1:
- comment_age = time.time() - comment.created_utc
- print comment_score, comment_age, time.strftime("%Y/%m/%d %H:%M:%S", time.gmtime(comment.created_utc)), comment.author, comment.permalink
- commentIDs_downvoted.append(comment.id)
- if str(comment.author) not in targeted_downvotes:
- targeted_downvotes.append(str(comment.author))
- elif (now - timeframeOldest) < comment.created_utc < (now - timeframeNewest) and comment_score > 1:
- comment_age = time.time() - comment.created_utc
- print comment_score, comment_age, time.strftime("%Y/%m/%d %H:%M:%S", time.gmtime(comment.created_utc)), comment.author, comment.permalink
- commentIDs_upvoted.append(comment.id)
- if str(comment.author) not in targeted_upvotes:
- targeted_upvotes.append(str(comment.author))
- while True:
- while True:
- try:
- get_comments(subreddit)
- time.sleep(2)
- except:
- print "crashed..."
- continue
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement