Skip to content

Instantly share code, notes, and snippets.

@haldean
Last active January 2, 2016 01:58
Show Gist options
  • Save haldean/8233439 to your computer and use it in GitHub Desktop.
Save haldean/8233439 to your computer and use it in GitHub Desktop.
yantoo
#!/usr/bin/env python
import praw
import pickle
import time
COMMENT_TEXT = '''
[You are never the only one.](http://youarenevertheonlyone.com)
'''.strip()
try:
with open('done.bin', 'rb') as f:
done = pickle.load(f)
except:
done = set()
last = None
r = praw.Reddit(user_agent='yantoo/1.0 by /u/haldean')
r.login('youarenevertheonlyon', 'hunter2')
while True:
comments = r.get_comments('all', limit=None)
for comment in comments:
if comment.id in done:
continue
elif comment.body.lower().startswith('am i the only one'):
print 'Found %s' % comment
try:
comment.reply(COMMENT_TEXT)
done.add(comment.id)
except praw.errors.APIException as e:
print 'Couldn\'t respond: %s' % e
last = comment.id
with open('done.bin', 'wb') as f:
pickle.dump(done, f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment