Advertisement
zero4

Untitled

Dec 20th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. import praw
  2. import time
  3.  
  4. SUBREDDIT_NAME = 'all'
  5.  
  6. paparia = {
  7.    'keyword': 'comment',
  8.  
  9. }
  10.  
  11. USERNAME = 'username4'
  12. PASSWORD = 'paok1926'
  13. CLIENT_ID = 'W944x_43R3CFRQ'
  14. CLIENT_SECRET = 'GHppRGyip9n5eM-3E9fS90r_0hw'
  15.  
  16. USER_AGENT = 'script:reply to keywords in titless:v0.2:written by /u/doug89'
  17.  
  18.  
  19. print("Authenticating...")
  20. reddit = praw.Reddit(
  21.     client_id=CLIENT_ID,
  22.     client_secret=CLIENT_SECRET,
  23.     password=PASSWORD,
  24.     user_agent=USER_AGENT,
  25.     username=USERNAME)
  26. print("Authenticaed as {}".format(reddit.user.me()))
  27.  
  28. print('Starting submission stream...')
  29. # NOTE: this was the old code. Keep for reference
  30. #for post in reddit.subreddit(SUBREDDIT_NAME).stream.submissions():
  31. #    if post.saved:
  32. #        continue
  33. #    has_keyword = any(k.lower() in post.title.lower() for k in KEYWORDS)
  34. #    not_self = post.author == reddit.user.me()
  35. #    if has_keyword and not_self:
  36. #        post.save()
  37. #        reply = post.reply(RESPONSE)
  38. #        print('http://reddit.com{}'.format(reply.permalink()))
  39.  
  40.      
  41. # magic happens here
  42. for post in reddit.subreddit(SUBREDDIT_NAME).stream.submissions():
  43.      print('I am a post!!! : ');
  44.      if post.saved:
  45.         continue
  46.      for key in paparia:
  47.         if key.lower() in post.title.lower():
  48.             print('I found: ', key)
  49.             post.save()
  50.             comment = paparia.get(key)
  51.             print('the comment is: ', comment)
  52.             reply = post.reply(comment)
  53.             time.sleep(60)
  54.             #print('http://reddit.com{}'.format(post.reply.permalink())) -- not working for some reason
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement