Advertisement
Guest User

Untitled

a guest
Dec 31st, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. import praw
  2.  
  3. reddit = praw.Reddit(client_id='',
  4. client_secret='',
  5. password='',
  6. user_agent='',
  7. username='')
  8.  
  9. readingfrom = reddit.submission('3ywu0b') # Last year's thread.
  10. body = author = []
  11. readingfrom.comments.replace_more(None)
  12. postingto = reddit.submission('5l9x4k') # Today's follow-up thread.
  13. for comment in readingfrom.comments:
  14. if comment.body == '[deleted]': # There could be more conditionals for common comment-overwriting scripts
  15. continue
  16. elif comment.author is None:
  17. continue
  18. body.append(comment.body)
  19. author.append(comment.author.name)
  20. commentcount = str(len(body))
  21. print 'I found ' + commentcount + ' comments to reply to.'
  22. 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
  23. body[x] = body[x].replace('\n', '\n> ') # Quote the user correctly with each line-break.
  24. try:
  25. 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])
  26. except (TypeError, UnicodeEncodeError): # I'm not actually sure this is needed or was a relic of testing.
  27. 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'))
  28. print str(x) + '/' + commentcount
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement