Guest User

Simple Reddit Comment Bot

a guest
Mar 24th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. import praw
  2. import time
  3.  
  4. ##### Login Credentials Here #####
  5.  
  6. user_login = ''
  7. pass_login = ''
  8.  
  9. ##### ##################### #####
  10.  
  11. reddit = praw.Reddit("simple script to look for and respond to reddit comments")
  12. reddit.login(username=user_login,password=pass_login)
  13.  
  14. checked = set()
  15.  
  16. while True:
  17.    
  18.     try:
  19.         x = 0 #counts how many comments we scan per iteration
  20.         all_comments = reddit.get_comments('all', limit=1000)
  21.        
  22.         for comment in all_comments:
  23.        
  24.             if 'whatever_you_are_looking_for' in str(comment) and comment.link_id[3:] not in checked:
  25.            
  26.                 checked.add(comment.link_id[3:])
  27.                 comment.reply('comment you want to reply with')
  28.                
  29.                 print "Just responded to a message!:"
  30.                 print comment.permalink
  31.                
  32.             else:
  33.                 pass
  34.                
  35.         # BOILERPLATE MESSAGE PRINTED AFTER EACH COMMENT SCAN
  36.         timeset = time.strftime("%m-%d %H:%M") # current date and time
  37.         print timeset
  38.         print "Just scanned " + str(x) + " comments.\n"
  39.         time.sleep(60)
  40.    
  41.     except Exception as e:
  42.    
  43.         # Reddit is down
  44.         # wifi is down
  45.         # some other problem etc       
  46.         print str(e)
Add Comment
Please, Sign In to add comment