Skip to content

Instantly share code, notes, and snippets.

@jakebloom
Last active August 29, 2015 14:13
Show Gist options
  • Save jakebloom/a9b1f88fbffceabad7bd to your computer and use it in GitHub Desktop.
Save jakebloom/a9b1f88fbffceabad7bd to your computer and use it in GitHub Desktop.
Reddit bot to follow /u/marktaylorofficial and thank him for his contribution
#!/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
@stev3bb
Copy link

stev3bb commented Jun 22, 2015

what is this XD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment