Skip to content

Instantly share code, notes, and snippets.

@rajtilakjee
Created June 26, 2023 05:21
Show Gist options
  • Save rajtilakjee/0f26c6b4a77916902f6fc89dc553131b to your computer and use it in GitHub Desktop.
Save rajtilakjee/0f26c6b4a77916902f6fc89dc553131b to your computer and use it in GitHub Desktop.
Reddit Flair Bot
import praw
import os
from dotenv import load_dotenv
load_dotenv()
reddit = praw.Reddit(
client_id=os.getenv('API_CLIENT'),
client_secret=os.getenv('API_SECRET'),
password=os.getenv('REDDIT_PASSWORD'),
user_agent="Winamp Music Bot for Reddit",
username=os.getenv('REDDIT_USERNAME'),
)
target_sub = "rajtilakjee"
subreddit = reddit.subreddit(target_sub)
trigger_phrase = "!flair"
for comment in subreddit.stream.comments():
if trigger_phrase in comment.body:
word = comment.body.replace(trigger_phrase,"")
author = comment.author
subreddit.flair.set(author,text=word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment