Last active
August 29, 2015 14:13
-
-
Save jakebloom/a9b1f88fbffceabad7bd to your computer and use it in GitHub Desktop.
Reddit bot to follow /u/marktaylorofficial and thank him for his contribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import praw | |
print "Tubby bot v0.1 by Jake" | |
print "======================\n" | |
print "Initialising praw reddit object" | |
r = praw.Reddit(user_agent="Tubby bot by Jake") | |
print "Logging in as tubby-bot" | |
r.login("tubby-bot") | |
print "Getting overview from /u/marktaylorofficial" | |
user = r.get_redditor("marktaylorofficial") | |
users = [] | |
print "Getting comments" | |
comments = user.get_comments() | |
comment = next(comments) | |
while True: | |
try: | |
print "\nCurrent comment:", | |
print comment | |
for reply in comment.replies: | |
users.append(reply.author.name) | |
if "tubby-bot" not in users: | |
print "Untouched comment. Replying now." | |
comment.reply("Thanks Tubbs") | |
else: | |
print "Already replied to this comment. Stopping now." | |
break | |
comment = next(comments) | |
users = [] | |
except Exception as e: | |
if str(e) == "": #If we run past all available comments, an empty exception is thrown | |
print "\nReplied to all comments. Stopping now." | |
else: | |
print e | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what is this XD