def postComment(self, sub, imgLink): sub.add_comment("{}\n\n I am A8582Image, I make images.".format(imgLink)) db_interface.addSub(sub.id)
def run(conf, r, i): print "# Imagerator running #" p, e, s = 0, 0, 0 sym = '\\' sym = updateCLI(sym,p,e,s) mostRecent = None while True: processed = 0 # get the sub subreddit = r.get_subreddit('A858DE45F56D9BC9') # if we've just started let's start from the begining, otherwise we'll pick up where we left off if mostRecent == None: subs = subreddit.get_new(limit=conf['block']) else: latest = "t3_{}".format(mostRecent) subs = subreddit.get_new(limit=conf['block'], params={'after': latest}) # churn through the submissions for submission in subs: try: # make sure it's not in already_done if r.haventReplied(submission): # get the text text = r.getSubText(submission) # make it into an image try: # try to turn it into an image i.makeImg(text) except: # if we fail, skip it db_interface.addSub(submission.id) p += 1 pass while True: try: # upload it imgLink = i.uploadImage(submission.id) try: # post it r.postComment(submission, imgLink) except: # start from the top and go again mostRecent = None break except: e += 1 sym = updateCLI(sym,p,e,s) time.sleep(5) pass p += 1 else: s += 1 if s > p: mostRecent = None except: e += 1 pass updateCLI(sym,p,e,s) print "\r\nDone" return True