Skip to content

Juddlyfire01/reddit

Repository files navigation

Reddit Automation Script

A Python script to automate Reddit interactions: search subreddits, comment on relevant posts, and manage DMs.

⚠️ Important Warnings

Before using this script, please be aware:

  1. Reddit's Terms of Service: Automated posting/commenting can violate Reddit's ToS if used for spam or self-promotion
  2. Rate Limits: Reddit API has strict rate limits (~60 requests per minute)
  3. Community Rules: Each subreddit has its own rules - respect them
  4. Spam Prevention: Reddit actively detects and bans spam accounts
  5. Best Practices: Only use this for legitimate, value-adding interactions

Setup

1. Install Dependencies

pip install -r requirements.txt

2. Create Reddit API Credentials

  1. Go to https://www.reddit.com/prefs/apps
  2. Click "create another app" or "create app"
  3. Choose "script" as the app type
  4. Note down your client_id and client_secret
  5. Set redirect URI to http://localhost:8080 (not used for scripts, but required)

3. Configure the Script

  1. Copy reddit_config.json.example to reddit_config.json
  2. Fill in your Reddit API credentials:
    {
        "client_id": "your_client_id_here",
        "client_secret": "your_client_secret_here",
        "user_agent": "MyApp/1.0 by YourUsername",
        "username": "your_reddit_username",
        "password": "your_reddit_password"
    }

4. (Optional) Setup Imgur for Media Sharing

  1. Register at https://api.imgur.com/oauth2/addclient
  2. Create an application and get your Client ID
  3. Use this ID when calling upload_media_to_imgur()

Usage

Basic Example

from reddit_automation import RedditAutomation

# Initialize
automation = RedditAutomation("reddit_config.json")

# Search and comment
subreddits = ["learnpython", "Python"]
posts = automation.search_subreddits(subreddits, "python tutorial", limit=10)
relevant = automation.filter_relevant_posts(posts, keywords=["learn", "beginner"])

for post in relevant:
    automation.comment_on_post(
        post, 
        "Great post! Here's a helpful resource: [link]",
        media_url="https://imgur.com/your_image.jpg"
    )

Full Automation

automation.run_automation(
    subreddits=["learnpython", "Python"],
    topic="python tutorial",
    keywords=["learn", "beginner", "help"],
    comment_template="Hi! I found your post helpful. Check this out: {post_title}",
    media_path="path/to/image.jpg",
    imgur_client_id="your_imgur_client_id"
)

Features

  • ✅ Search multiple subreddits for topics
  • ✅ Filter posts by keywords, score, and relevance
  • ✅ Comment on posts with custom templates
  • ✅ Share media files (via Imgur)
  • ✅ Send direct messages
  • ✅ Rate limiting and error handling

Reddit API Best Practices

  1. Don't spam: Only comment when you have genuine value to add
  2. Respect rate limits: The script includes delays, but be mindful
  3. Read subreddit rules: Some subreddits prohibit self-promotion
  4. Use descriptive user agent: Helps Reddit identify your app
  5. Monitor your account: Check for warnings or bans regularly

Limitations

  • Reddit doesn't allow direct media uploads in comments - must use external hosting (Imgur, etc.)
  • Some subreddits have restrictions on new accounts or low-karma accounts
  • Reddit may flag automated behavior - use sparingly and authentically
  • DM functionality requires the recipient to accept messages from non-friends (in some cases)

Legal & Ethical Considerations

  • Always disclose if you're using automation (if required by subreddit rules)
  • Don't use this for spam or harassment
  • Respect user privacy
  • Follow Reddit's content policy
  • Consider using this for legitimate community engagement only

Troubleshooting

Authentication errors: Double-check your credentials in reddit_config.json

Rate limit errors: Increase delays between requests

Permission errors: Some subreddits require approval before posting

Media upload fails: Verify your Imgur client ID is correct

License

Use responsibly and in accordance with Reddit's Terms of Service.

About

community bot

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages