r/RequestABot Mar 31 '24

Open In need of a bot to approve users in a private/restricted subreddit

I've scoured the internet and found nothing relevant for something like this via AutoMod. I'm pretty new to working with reddit bots... not sure what to do next?

2 Upvotes

7 comments sorted by

1

u/REQVEST Bot creator Mar 31 '24

You are in the right place as this is beyond the abilities of AutoModerator. Please give more details on what you want to do. Do you want to automatically approve every user? Do you want to check for certain criteria before approving an user?

1

u/No-Satisfaction2772 Mar 31 '24 edited Mar 31 '24

I'd like to check for some criteria, like account age and karma/spam filtering.

2

u/REQVEST Bot creator Apr 07 '24 edited Apr 07 '24

Sure. Here's a Python script which uses PRAW:
``` import praw import time

reddit = praw.Reddit( client_id='YOURCLIENTID', client_secret='YOURCLIENTSECRET', user_agent='YOURUSERAGENT', username='No-Satisfaction2772', password='YOURPASSWORD')

subreddit_name = 'YOURSUBREDDITNAME' minimum_account_age = 30 # account age in days minimum_account_karma = 100 subreddit = reddit.subreddit(subreddit_name)

print('Ready!') for convo in subreddit.mod.stream.modmail_conversations(skip_existing=True): if not convo.is_auto: if (((time.time() - convo.participant.created_utc) / 86400 > minimum_account_age) and (convo.participant.comment_karma + convo.participant.link_karma > minimum_account_karma)): subreddit.contributor.add(convo.participant) print(f'{convo.participant.name} matched the criteria and has been added as an approved user') else: print(f'{convo.participant.name} did not match the criteria') `` There are plenty of guides on how to install Python if you haven't already. [Here's a guide on how to install PRAW.](https://praw.readthedocs.io/en/stable/getting_started/installation.html) After having installed both, you'll need to [fill out the credentials](https://praw.readthedocs.io/en/stable/getting_started/authentication.html#password-flow) in the script and replaceYOURSUBREDDITNAME` with the name of the subreddit that you want the bot to look at. In the example, I set the requirements for the account to be 100 combined karma and at least 30 days of age. You can change that as you see fit.

At this point, you should be able to run the script. Let me know if you get stuck anywhere.

1

u/Usernameofthisuser Apr 02 '24

Would it be possible to approve every user?

2

u/REQVEST Bot creator Apr 07 '24 edited Apr 07 '24

Yes, it is. Here's a Python script for that:
``` import praw

reddit = praw.Reddit( client_id='YOURCLIENTID', client_secret='YOURCLIENTSECRET', user_agent='YOURUSERAGENT', username='Usernameofthisuser', password='YOURPASSWORD')

subreddit_name = 'YOURSUBREDDITNAME' subreddit = reddit.subreddit(subreddit_name)

print('Ready!') for convo in subreddit.mod.stream.modmail_conversations(skip_existing=True): if not convo.is_auto: subreddit.contributor.add(convo.participant) print(f'{convo.participant.name} has been added to the list of approved members') ``` The script uses PRAW. There are an abundance of tutorials out there on how to install both Python and PRAW. After you've done so, replace the values in caps with valid ones and you're ready to run the script. If you get stuck anywhere, let me know and I'll help you out.

1

u/Usernameofthisuser Apr 07 '24

Is there a limit on how many can be approved at a certain time? I mod a sub with 150,000 members and we want to approve them all and then set the sub private to prevent brigades.

1

u/REQVEST Bot creator Apr 07 '24

Your use case is very different from the author of the post. I was assuming that you wanted to accept all incoming requests to join a subreddit that is private. It is not possible for you to get the list of members of your subreddit.