Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 and not_banned:
- try:
- comment.save()
- reply = comment.reply(RESPONSE)
- print(datetime.datetime.now())
- time.sleep(660)
- except Exception as e:
- if e.error_type == 'SUBREDDIT_NOTALLOWED':
- print('Banned from some_sub')
- else:
- print(e)
- else:
- for comment in comments:
- if comment.score < -5:
- comment.delete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement