Created
June 26, 2023 05:21
-
-
Save rajtilakjee/0f26c6b4a77916902f6fc89dc553131b to your computer and use it in GitHub Desktop.
Reddit Flair Bot
This file contains 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 | |
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