Advertisement
Guest User

repostBot.py

a guest
Jun 6th, 2017
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import praw
  4. import config
  5.  
  6. class color:
  7.    BOLD = "\033[1m"
  8.    END = "\033[0m"
  9.  
  10. def bot_login():
  11.     print("Logging in")
  12.     r = praw.Reddit(username = config.username,
  13.                     password = config.password,
  14.                     client_id = config.client_id,
  15.                     client_secret = config.client_secret,                    
  16.                     user_agent = "repostBot v0.1")
  17.     print "Login successful"
  18.  
  19.     return r
  20.  
  21. def run_bot(r):
  22.     print("Obtaining post URL's")
  23.     #Loop through new posts
  24.     for post in r.subreddit("pics").hot(limit=500):
  25.       #Check if Post URL is already in Top 1000 Posts
  26.              with open("TopPosts") as f:
  27.                 for line in f:
  28.                   if post.url in line and post.id not in line:
  29.                     print(post.title + " https://www.reddit.com/r/pics/" + post.id + '\n')
  30.                     original = line
  31.                     post.reply("This is a dirty repost, here is the original and the image source: " + original + '\n' + '\n' + "If you think that I don't do my job correctly send me a DM, I dare you")
  32.          
  33.  
  34. r = bot_login()
  35.  
  36. run_bot(r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement