Skip to content

Instantly share code, notes, and snippets.

@JakenHerman
Last active September 1, 2021 05:15
Show Gist options
  • Save JakenHerman/6683447e469d5f5a069da4e8f03e9d5d to your computer and use it in GitHub Desktop.
Save JakenHerman/6683447e469d5f5a069da4e8f03e9d5d to your computer and use it in GitHub Desktop.
import os
import praw
from supabase_py import create_client, Client
reddit = praw.Reddit(
username = os.environ.get('REDDIT_USERNAME'),
password = os.environ.get('REDDIT_PASSWORD'),
client_id = os.environ.get('API_CLIENT'),
client_secret = os.environ.get('API_SECRET'),
user_agent = "Scooby Searcher Bot"
)
url: str = os.environ.get("SUPABASE_URL")
key: str = os.environ.get("SUPABASE_KEY")
supabase: Client = create_client(url, key)
comments = supabase.table("comment_ids").select("*").execute()
comments_already_responded_to = [comment['id'] for comment in comments.get("data", [])]
for comment in reddit.subreddit('cartoons').comments(limit=1000):
if "scooby dooby doo" in comment.body.lower() and comment.id not in comments_already_responded_to:
comment.reply("Where are you?")
data = supabase.table("comment_ids").insert({"id":comment.id,"comment_body":comment.body}).execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment