Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import time
- SUBREDDIT_NAME = 'all'
- paparia = {
- 'keyword': 'comment',
- }
- USERNAME = 'username4'
- PASSWORD = 'paok1926'
- CLIENT_ID = 'W944x_43R3CFRQ'
- CLIENT_SECRET = 'GHppRGyip9n5eM-3E9fS90r_0hw'
- USER_AGENT = 'script:reply to keywords in titless:v0.2:written by /u/doug89'
- print("Authenticating...")
- reddit = praw.Reddit(
- client_id=CLIENT_ID,
- client_secret=CLIENT_SECRET,
- password=PASSWORD,
- user_agent=USER_AGENT,
- username=USERNAME)
- print("Authenticaed as {}".format(reddit.user.me()))
- print('Starting submission stream...')
- # NOTE: this was the old code. Keep for reference
- #for post in reddit.subreddit(SUBREDDIT_NAME).stream.submissions():
- # if post.saved:
- # continue
- # has_keyword = any(k.lower() in post.title.lower() for k in KEYWORDS)
- # not_self = post.author == reddit.user.me()
- # if has_keyword and not_self:
- # post.save()
- # reply = post.reply(RESPONSE)
- # print('http://reddit.com{}'.format(reply.permalink()))
- # magic happens here
- for post in reddit.subreddit(SUBREDDIT_NAME).stream.submissions():
- print('I am a post!!! : ');
- if post.saved:
- continue
- for key in paparia:
- if key.lower() in post.title.lower():
- print('I found: ', key)
- post.save()
- comment = paparia.get(key)
- print('the comment is: ', comment)
- reply = post.reply(comment)
- time.sleep(60)
- #print('http://reddit.com{}'.format(post.reply.permalink())) -- not working for some reason
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement