Advertisement
kungming2

TGP Check for No Flairs

Mar 13th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. import praw
  2.  
  3. BOT_NAME = 'The Good Place No-Flair Janet'
  4. VERSION_NUMBER= '0.1'
  5. USER_AGENT = BOT_NAME + ' ' + VERSION_NUMBER + ',  a service bot for this account written by u/kungming2.'
  6. SUBREDDIT = "thegoodplace"
  7. USER_NAME = ""
  8.  
  9.  
  10. print('\n|======================Logging in...======================|')
  11.  
  12.  
  13. reddit = praw.Reddit(client_id="",
  14.                      client_secret="", password='',
  15.                      user_agent=USER_AGENT, username=USER_NAME)
  16.  
  17.  
  18. def check_for_unflaired():
  19.  
  20.     posts_unflaired_lines = []
  21.     line_template = "* [{}]({})"
  22.     posts = []
  23.     posts += reddit.subreddit(SUBREDDIT).new(limit=100)
  24.    
  25.     for post in posts:
  26.        
  27.         if post.link_flair_text is None:
  28.             new_line = line_template.format(post.title, post.permalink)
  29.             posts_unflaired_lines.append(new_line)
  30.            
  31.     if len(posts_unflaired_lines) > 0:
  32.         header = "\n### {} unflaired posts on r/{}:\n\n".format(len(posts_unflaired_lines), SUBREDDIT)
  33.         returned_text = header + '\n'.join(posts_unflaired_lines)
  34.     else:
  35.         returned_text = "No unflaired posts found on r/{}.".format(SUBREDDIT)
  36.        
  37.     return returned_text
  38.        
  39.        
  40. print(check_for_unflaired())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement