Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. import praw
  2. import datetime
  3. import config
  4. import time
  5.  
  6. title = "Thank you for posting to /r/Aquariums"
  7. message = "Thank you for posting to our subreddit. We want to remind you to please **flair your submission with an appropriate link flair**. If you are on desktop the flair option can be found under the title of your post. On mobile applications it will be with your other post options (delete, save, share, etc)
  8.  
  9. def bot_login():
  10.    reddit = praw.Reddit(username = config.username,
  11.            password = config.password,
  12.            client_id = config.client_id,
  13.            client_secret = config.client_secret,
  14.            user_agent = "Aquarium Bot v0.1")
  15.    
  16.    return reddit
  17.    
  18. def run_bot(reddit):
  19.    for submission in reddit.subreddit('AquariumsTestSub').new(limit=20):
  20.        posttime = get_dif(submission)
  21.        if posttime > datetime.timedelta(minutes=10) and posttime < datetime.timedelta(minutes=12) and submission.link_flair_text is None:
  22.            submission.author.message(title, message)
  23.        
  24. def get_dif(submission):
  25.    date = datetime.datetime.fromtimestamp(submission.created_utc)
  26.    dif = datetime.datetime.utcnow() - date
  27.    
  28.    return dif - datetime.timedelta(hours=4)
  29.  
  30. reddit = bot_login()
  31.  
  32. while True:
  33.    run_bot(reddit)
  34.    print "Done loop!"
  35.  
  36.    time.sleep(118)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement