Last active
March 27, 2019 07:18
-
-
Save gavin19/9b2fe7e7d8d41e0cba7bb401a3169b43 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 | |
CMT_PHRASE = "some phrase" | |
PARENT_PHRASE = "another phrase" | |
r = praw.Reddit(...) | |
cmt_stream = r.subreddit("pics").stream.comments(skip_existing=True) | |
def check phrase(cmt, parent): | |
c = CMT_PHRASE in cmt.body.lower() | |
p = PARENT_PHRASE in parent.body.lower() | |
return c and p: | |
def parse_cmt(cmt): | |
if cmt.parent_id[:3] == "t1_": # only proceed if the parent is a comment | |
if check_phrase(cmt, parent): | |
cmt.reply("Something to reply with here") | |
for cmt in cmt_stream: | |
parse_cmt(cmt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment