SHOW:
|
|
- or go back to the newest paste.
| 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: |
| 24 | + | x+=1 |
| 25 | ||
| 26 | if 'phrase you are looking for' in str(comment) and comment.link_id[3:] not in checked: | |
| 27 | ||
| 28 | checked.add(comment.link_id[3:]) | |
| 29 | comment.reply('comment you want to reply with')
| |
| 30 | ||
| 31 | print "Just responded to a message!:" | |
| 32 | print comment.permalink | |
| 33 | print "\n\n" | |
| 34 | ||
| 35 | else: | |
| 36 | pass | |
| 37 | ||
| 38 | # BOILERPLATE MESSAGE PRINTED AFTER EACH COMMENT SCAN | |
| 39 | timeset = time.strftime("%m-%d %H:%M") # current date and time
| |
| 40 | print timeset | |
| 41 | print "Just scanned " + str(x) + " comments.\n" | |
| 42 | time.sleep(60) | |
| 43 | ||
| 44 | except Exception as e: | |
| 45 | ||
| 46 | # Reddit is down | |
| 47 | # wifi is down | |
| 48 | # some other problem etc | |
| 49 | print str(e) |