Skip to content

RFC: Ability to add resources from the Subreddit #62

Description

@Bhupesh-V

Feature details?

The flow:

  • We have a Resources flair on Reddit.
  • Every few days, run a cron that finds all posts under this flair.
  • Check the comments of each post to see if someone shared a "link" to the resource.
  • If found, figure out which file to add it into.
  • Create a single or multiple PRs.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. changed the title [-]RFC: Ability to add watch and add resources from the Subreddit[/-] [+]RFC: Ability to add resources from the Subreddit[/+] on Feb 15, 2024
  2. Alucard2169 commented on Apr 17, 2024

    @Alucard2169
    Contributor

    I think that adding this to the wiki on the sub Reddit and defining a proper format would be much more feasible.

    We can have a mega thread and a Reddit bot, so if we see any link shared around, we can call the bot to check if the link is already added into resource list. The links that do pass this check will get added to the resource mega thread, from where we can add them into the repo.

    (Alternatively, we can keep a list of links that were added through Reddit in the repo in JSON format, that would avoid duplicate links from getting into the repo and also will serve as a record library).

    Also, we can call the bot automatically under every comment or post that shares a link and remind them of the format.

  3. LinearArray commented on Apr 17, 2024

    @LinearArray
    Member

    We can create a script in https://github.com/developersIndia/deviras for that.

  4. Alucard2169 commented on Apr 17, 2024

    @Alucard2169
    Contributor

    Yep, the closest I can see is the community thread script, that grabs posts from community thread, we can create a similar one that can collect links from posts and comments from Subreddit when it's called.

    I will start working on it, just give me some time to go through the code base.

  5. LinearArray commented on Apr 17, 2024

    @LinearArray
    Member

    we can make it auto-call it itself from resource flaired posts or we can just add a !resource commands for mods to run.

  6. LinearArray commented on Apr 17, 2024

    @LinearArray
    Member
     for comment in subreddit.stream.comments():
            if COMMAND in comment.body and comment.author in subreddit.moderator():
            # insert logic here
                comment.reply(RESOURCE)
                print("Resource shared successfully.")
    

    should be easy with praw

  7. Alucard2169 commented on Apr 17, 2024

    @Alucard2169
    Contributor

    Looks good, but that's assuming that people would actually properly flair their posts.

    There could be a lot of posts that can have discussion flair but still a lot of links, we definitely need the !resource command for that so mods themselves can perform the action.

  8. Alucard2169 commented on Apr 17, 2024

    @Alucard2169
    Contributor

    How about something like this:

    sub = "developersIndia"
    subreddit = reddit.subreddit(sub)
    
    resourceLinks = set()  # set to avoid duplicate links
    
    # Loop through submissions with the flair 'resources'
    for submission in subreddit.search("flair:resources"):
        # Fetch comments for the submission
        submission.comments.replace_more(limit=None)
        for comment in submission.comments.list():
            # Extract resource links from comment body
            resource_links = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', comment.body)
            # Add unique links to the set
            resourceLinks.update(resource_links)
    
    

    But we do need a set rule, like asking users to post resources like [JavaScript] (<resource>), that would help out in filtering the already existing list of resources and avoid duplicate addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions