orbit-love / github-actions-templates

Starter GitHub Actions templates to get you up and running with community built integrations
51 stars 41 forks source link

Reddit intregration - only add posts and comments that include a specified keyword #17

Closed jansenbob closed 3 years ago

jansenbob commented 3 years ago

Hi there.

First of all, thanks for the super useful action templates. I have close to zero programming skills (UX designer here) and I managed to get it up and running. This is also my first Github issue, so excuse me if I'm breaking any rules.

What I would like to achieve with the reddit integration is to see if anyone in a specific subreddit is mentioning our project (objectiv). I did manage to pull in all comments and posts from specific subreddits, but that's a bit much if the topic is broad.

Example: I would like to get notified if there are any new posts/comments in r/dataengineering that mention 'objectiv'.

I've tried looking into the Reddit API if such a thing is supported OOTB, but couldn't directly find it.

WDYT? Would this be a useful enhancement?

phazonoverload commented 3 years ago

Thanks for this - and don't worry this is a perfect issue: a compliment, an ask, an example. šŸ˜‰

This is actually completely possible if you use the package as I've split out the 'getting' of posts/comments and the 'adding to orbit' so in between those operations you can filter results. That functionality can also be baked-in so you can use it in the GitHub Actions template. I'm working on some other integrations over the next few days so I will swing round to this likely late next week.

jansenbob commented 3 years ago

Thanks for the prompt response. Looking forward to it.

phazonoverload commented 3 years ago

This is now done! Take a look at the new Reddit README in this repo for instructions šŸ˜„

jansenbob commented 3 years ago

Great stuff! thanks so much. I'll give it a try today and will let you know if I run into anything.

edit: Worked like a charm. Thanks again!

jansenbob commented 3 years ago

@phazonoverload so the results have been getting in an it's working, but it also triggers when someone writes objective instead of objectiv. Is there any way I can prevent that? like put it in backticks or something? Cheers.

here's how i've written it down: - run: npx @orbit-love/reddit --posts --comments --hours=1 --subreddit "${{ matrix.subreddit }}" --filter="objectiv"

phazonoverload commented 3 years ago

Hi @jansenbob. This filter works by looking for the combination of characters provided in the wider text, and does not support 'exclusions' such as "give me objectiv but not if there's an e on the end". This is a pretty specialised use-case so I won't be building it into this integration.

You can repeat the run step in your workflow with variations though to try and isolate just the word 'objectiv'. For example you do one for objectiv., one for objectiv (with a space at the end) and objectiv,. This isn't foolproof as you'll miss other punctuation such as quotes, semicolons, etc, but will do a better job of isolating the desired term that what there is at the moment.

Hope this helps!

jansenbob commented 3 years ago

Thanks for getting back Kevin. Makes sense. One of our guys was talking about turning it into a regexp.

For now, I'll use your workaround. If we decide to build something ourselves i'll drop you a line.

Cheers.

phazonoverload commented 3 years ago

Iā€™d welcome a pull request which supports regex for filtering šŸ˜„