Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import os
- import time
- import datetime
- from multiprocessing import Process
- SUBREDDIT_NAME = 'all'
- KEYWORDS = [snip]
- RESPONSE = [snip]
- BANNED_USERS = [snip]
- USERNAME = [redacted]
- PASSWORD = [redacted]
- CLIENT_ID = [redacted]
- CLIENT_SECRET = [redacted]
- USER_AGENT = 'script:reply to keywords in comments: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()))
- comments = reddit.user.me().comments.new(limit=None)
- def loop():
- for comment in reddit.subreddit(SUBREDDIT_NAME).stream.comments(pause_after=1):
- if comment is None:
- break
- if comment.saved:
- continue
- has_keyword = any(k.lower() in comment.body.lower() for k in KEYWORDS)
- not_self = comment.author != reddit.user.me()
- not_banned = comment.author != BANNED_USERS
- if has_keyword and not_self and not_banned:
- try:
- comment.save()
- reply = comment.reply(RESPONSE)
- print(datetime.datetime.now())
- except:
- pass
- for comment in comments:
- if comment.score < -5:
- comment.delete()
- x = 1
- while True:
- loop()
Add Comment
Please, Sign In to add comment