Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import os
- r = praw.Reddit(username='username', password='password', client_id='app_id', client_secret='app_secret', user_agent='comment notifier for cuddlefishcat')
- if not os.path.isfile("commentsRead.txt"):
- commentsRead = []
- else:
- with open("commentsRead.txt", "r") as f:
- commentsRead = f.read()
- commentsRead = commentsRead.split("\n")
- commentsRead = list(filter(None, commentsRead))
- subreddits = ['subreddit1', 'subreddit2']
- for subreddit in subreddits:
- for comment in r.subreddit(subreddit).comments(limit=10):
- if comment.id not in commentsRead:
- print 'sent comment ' + comment.permalink
- r.redditor('targetuser').message('New comment in ' + subreddit, ' here\'s the text:\n\n' + comment.body + '\n\n' + comment.permalink)
- commentsRead.append(comment.id)
- with open("commentsRead.txt", "w") as f:
- for post_id in commentsRead:
- f.write(post_id + "\n")
Add Comment
Please, Sign In to add comment