Skip to content

Instantly share code, notes, and snippets.

@gavin19
Last active March 27, 2019 07:18
Show Gist options
  • Save gavin19/9b2fe7e7d8d41e0cba7bb401a3169b43 to your computer and use it in GitHub Desktop.
Save gavin19/9b2fe7e7d8d41e0cba7bb401a3169b43 to your computer and use it in GitHub Desktop.
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