Last active
January 2, 2016 01:58
-
-
Save haldean/8233439 to your computer and use it in GitHub Desktop.
yantoo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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