Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- reddit = praw.Reddit(client_id='',
- client_secret='',
- password='',
- user_agent='',
- username='')
- readingfrom = reddit.submission('3ywu0b') # Last year's thread.
- body = author = []
- readingfrom.comments.replace_more(None)
- postingto = reddit.submission('5l9x4k') # Today's follow-up thread.
- for comment in readingfrom.comments:
- if comment.body == '[deleted]': # There could be more conditionals for common comment-overwriting scripts
- continue
- elif comment.author is None:
- continue
- body.append(comment.body)
- author.append(comment.author.name)
- commentcount = str(len(body))
- print 'I found ' + commentcount + ' comments to reply to.'
- for x in range(0, len(body)): # if the bot barfs, it'll print the last comment completed to the console, replace 0 with the next one to process
- body[x] = body[x].replace('\n', '\n> ') # Quote the user correctly with each line-break.
- try:
- postingto.reply('/u/' + author[x] + '\n\nExactly one year ago, I asked what you wanted to achieve by 31st Dec 2016 and I said I would message you to see if you achieved it. Well, today is the day!\n\nYour goal was:\n\n> ' + body[x])
- except (TypeError, UnicodeEncodeError): # I'm not actually sure this is needed or was a relic of testing.
- postingto.reply('/u/' + author[x] + '\n\nExactly one year ago, I asked what you wanted to achieve by 31st Dec 2016 and I said I would message you to see if you achieved it. Well, today is the day!\n\nYour goal was:\n\n> ' + body[x].encode('utf8'))
- print str(x) + '/' + commentcount
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement