Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove dead / private subreddits #82

Merged
merged 1 commit into from
Jan 29, 2024
Merged

Conversation

Motzumoto
Copy link
Contributor

Had to make an entirely new pr because github fucked my branch.

Anyway, heres the code i used to check if the branches were dead / private. It uses praw which is blocking. However if you want an async version please let me know and ill give you an async version.

I had to change how things were listed, see screenshot: https://i.hep.gg/7PXwCsvWM

import praw
from prawcore.exceptions import NotFound, Redirect, Forbidden

categories = {
    # Subreddits
    "FOUR_K": [
        "Hegre",
        "HighResNSFW",
        "NSFW_Wallpapers",
        "UHDnsfw",
        "closeup",
    ],
    "AHEGAO": ["AhegaoGirls", "EyeRollOrgasm", "O_Faces", "RealAhegao"],
    "ASS": [
        "AssOnTheGlass",
        "AssholeBehindThong",
        "ButtsAndBareFeet",
        "HungryButts",
        "Mooning",
        "SnakeButt",
        "TheUnderbun",
        "Upshorts",
        "ass",
        "asshole",
        "assinthong",
        "asstastic",
        "beautifulbutt",
        "bigasses",
        "booty",
        "datgap",
        "girlsinleggings",
        "girlsinyogapants",
        "hugeass",
        "paag",
        "pawg",
        "facedownassup",
]
   # every other category
}

reddit = praw.Reddit(
    client_id="8FTlc5hmH9lBGA",
    client_secret="oxZfsfCoL4o0eu_VBLh21o6mZmg",
    password="74MMBFDa3hHo",
    user_agent="asyncprawpython",
    username="OwO_ExaNori",
)

class SubStatus:
    SUB_GONE = "Subreddit Gone"
    SUB_EXISTS = "Subreddit Exists"

def check_banned_subreddits(category, subreddits):
    banned_subreddits = []

    for subreddit_name in subreddits:
        try:
            subreddit = reddit.subreddit(subreddit_name)
            # Accessing subreddit information to check existence
            subreddit.title
        except NotFound:
            # Subreddit does not exist
            print(f"Subreddit {subreddit_name} not found.")
        except Redirect:
            # Subreddit does not exist or has been banned
            banned_subreddits.append(subreddit_name)
        except Forbidden:
            # Subreddit is forbidden (403)
            print(f"Access forbidden for subreddit {subreddit_name}.")

    return banned_subreddits

# Check for banned subreddits in each category
banned_subreddits = []
for category, subreddits in categories.items():
    banned_subreddits.extend(check_banned_subreddits(category, subreddits))

if banned_subreddits:
    print(f"Banned subreddits: {', '.join(banned_subreddits)}")
else:
    print("No banned subreddits.")

Had to make an entirely new pr because github fucked my branch
@Motzumoto
Copy link
Contributor Author

also dont worry the secrets and passwords in the code are invalid

Copy link
Owner

@PredaaA PredaaA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@PredaaA PredaaA merged commit ca53bc5 into PredaaA:master Jan 29, 2024
1 of 2 checks passed
@Ginpachi98
Copy link

adjusted this cog by making people pay with economy currency (which they earn by !work or !payday daily) in order to reduce spam and it's been the backbone of our local town small community server, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants