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

RFC: Ability to add resources from the Subreddit #62

Open
1 task done
Bhupesh-V opened this issue Jan 23, 2024 · 7 comments
Open
1 task done

RFC: Ability to add resources from the Subreddit #62

Bhupesh-V opened this issue Jan 23, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@Bhupesh-V
Copy link
Member

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
@Bhupesh-V Bhupesh-V added the enhancement New feature or request label Jan 23, 2024
@Bhupesh-V Bhupesh-V changed the title RFC: Ability to add watch and add resources from the Subreddit RFC: Ability to add resources from the Subreddit Feb 15, 2024
@Alucard2169
Copy link
Contributor

Alucard2169 commented Apr 17, 2024

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.

@LinearArray
Copy link
Member

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

@Alucard2169
Copy link
Contributor

Alucard2169 commented Apr 17, 2024

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.

@LinearArray
Copy link
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.

@LinearArray
Copy link
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

@Alucard2169
Copy link
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.

@Alucard2169
Copy link
Contributor

Alucard2169 commented Apr 17, 2024

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
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants