Created
June 26, 2023 05:24
-
-
Save rajtilakjee/ede7f15b33add40442da7fe69388d26f to your computer and use it in GitHub Desktop.
Reddit Modmail 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 discord | |
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="Reddit Modmail Bot", | |
username=os.getenv('REDDIT_USERNAME'), | |
check_for_async=False | |
) | |
target_sub = "rajtilakjee" | |
subreddit = reddit.subreddit(target_sub) | |
webhook = discord.Webhook.from_url(os.getenv('DISCORD_URL'), adapter=discord.RequestsWebhookAdapter()) | |
for modmail_conversation in subreddit.mod.stream.modmail_conversations(state='new'): | |
author=str(modmail_conversation.authors[0]) | |
webhook.send("New Modmail from " + author) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment