Advertisement
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]
- USERNAME = [SNIP]
- PASSWORD = [SNIP]
- CLIENT_ID = [SNIP]
- CLIENT_SECRET = [SNIP]
- 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()))
- def get_list_of_banned_subreddits():
- p = re.compile(r"(?<=You have been banned from participating in )(.*)(?=. You can still view and subscribe)")
- bot_user = reddit_client.redditor('RickrollingIsDead')
- messages = reddit_client.inbox.messages()
- return [p.search(m.body).group(0) for m in messages if p.search(m.body)]
- COMMENTS = reddit.user.me().comments.new(limit=None)
- print("Stream has been started at", datetime.datetime.now())
- x = 1
- while True:
- for comment in reddit.subreddit(SUBREDDIT_NAME).stream.comments():
- if comment.saved:
- continue
- reddit.submission(test_post).delete()
- has_keyword = any(k.lower() in comment.body.lower() for k in KEYWORDS)
- not_self = comment.author != reddit.user.me()
- if has_keyword and not_self:
- comment.save()
- reply = comment.reply(RESPONSE)
- print(datetime.datetime.now())
- time.sleep(660)
- for comment in comments:
- if comment.score < -5:
- comment.delete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement