Created
February 6, 2020 19:55
-
-
Save gavin19/42d4af576fcd3ff707182d85493f4055 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import praw | |
userAgent = 'xxx' | |
cID = 'xxx' | |
cSC= 'xxx' | |
userN = 'xxx' | |
userP ='xxx' | |
numFound = 0 | |
reddit = praw.Reddit(user_agent=userAgent, | |
client_id=cID, | |
client_secret=cSC, | |
username=userN, | |
password=userP) | |
subreddit = reddit.subreddit('xxx') | |
keywords = { | |
'phrase one': 'reply for phrase one', | |
'phrase two': 'reply for phrase two', | |
'phrase three': 'reply for phrase three', | |
'phrase four': 'reply for phrase four' | |
} | |
def match_phrase(kw, cmt): | |
if kw in cmt: | |
return True | |
return False | |
for comment in subreddit.stream.comments(skip_existing=True): | |
cmt = comment.body.lower() | |
for kw in keywords: | |
if match_phrase(kw, cmt): | |
print("---------------------------------") | |
print("Found: " + kw) | |
print('Bot saying: ', keywords[kw]) | |
comment.reply(keywords[kw]) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment