Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import time
- r = praw.Reddit(user_agent = "Depression help bot By /u/Depression_help_bot and /u/playgrop")
- r.login("Depression_help_bot","*censored*")
- print("Logging in...")
- words_to_match = ["depression", "depressed", "suicidal", "suicide", "take my own life", "kill myself"]
- cache = []
- def run_bot():
- print("Grabbing Subreddit")
- subreddit = r.get_subreddit("pcmasterrace")
- print("Grabbing Comments")
- comments = subreddit.get_comments(limit=50)
- for comment in comments:
- comment_text = comment.body.lower()
- isMatch = any(string in comment_text for string in words_to_match) and if not Depression_help_bot in comment_author_name
- if comment.id not in cache and isMatch:
- print("Match Found! Comment ID: " + comment.id)
- comment.reply("If you are suicidal or know anybody struggeling with depression you should seek help. An example would be here [here](http://www.suicide.org/international-suicide-hotlines.html). ____ Bleep Boop! I am a bot. If you found any problems message me [here](https://www.reddit.com/message/compose/?to=Depression_help_bot)")
- print("Reply sucessfull")
- cache.append(comment.id)
- print("Comment loop finished")
- while True:
- run_bot()
- time.sleep(30)
Add Comment
Please, Sign In to add comment