Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. import praw
  2. import datetime
  3. import time
  4.  
  5. def main():
  6.  
  7.     reddit = praw.Reddit(client_id='',
  8.                         client_secret='',
  9.                         password='',
  10.                         username='',
  11.                         user_agent='my user agent')
  12.  
  13.     target_subreddit = reddit.subreddit('7330313')
  14.                        
  15.     current_time=datetime.datetime.now()
  16.     current_time=current_time.replace(second=0,microsecond=0)
  17.  
  18.     for submission in target_subreddit.stream.submissions():
  19.         submission_checker(submission)
  20.  
  21.  
  22.  
  23. def submission_checker(submission):
  24.         comment_authors=[]
  25.         print("Thread title: " + submission.title)
  26.         print("Minutes since post: ")
  27.         thread_age = datetime.datetime.now(datetime.timezone.utc).timestamp()-submission.created_utc
  28.         thread_age = thread_age/60
  29.         print(thread_age)
  30.        
  31.         for top_level_comment in submission.comments:
  32.                 comment_authors.append(top_level_comment.author.name)
  33.                
  34.         print( "OP = " + str(submission.author))
  35.         print("Commenters: " + str(comment_authors) + "\n")
  36.        
  37.         if submission.author in comment_authors:
  38.             print("OP Commented.\n\n")
  39.        
  40.         if thread_age > 10:
  41.             if submission.author not in comment_authors:
  42.                 print("Thread overdue.\nOP has not commented\n")
  43.                 submission.mod.remove()
  44.                 print("Thread removed.")
  45.         print("----------------------------------------------------------\n")
  46.  
  47. if __name__ == '__main__':
  48.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement