Skip to content

Commit

Permalink
update scripts for Reddit
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdbd committed Jun 3, 2024
1 parent 35098ff commit 37737bd
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reddit-freelancing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Reddit freelancing'

on:
# schedule:
# - cron: '45 23 * * 1'
# - cron: '45 23 * * 1' # UTC time
workflow_dispatch:
# You can trigger this workflow manually using the GitHub CLI:
# gh workflow run "Reddit freelancing" --ref branch-name
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reddit-links-to-telegram.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
schedule:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# https://crontab.guru/
- cron: '55 9 * * 1'
- cron: '55 9 * * 1' # UTC time
workflow_dispatch:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
# You can trigger this workflow manually using the GitHub CLI:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reddit-search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Reddit search'

on:
schedule:
- cron: '45 23 * * 1'
- cron: '45 23 * * 1' # UTC time
workflow_dispatch:
# You can trigger this workflow manually using the GitHub CLI:
# gh workflow run "Reddit search" --ref branch-name
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reddit-website-audit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'r/slavelabour Website Audit'

on:
# schedule:
# - cron: '45 15 * * 2'
# - cron: '45 15 * * 2' # UTC time
workflow_dispatch:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
# You can trigger this workflow manually using the GitHub CLI:
Expand Down
34 changes: 21 additions & 13 deletions scripts/reddit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ As far as I know, search queries are always [case insensitive](https://www.reddi

## Search Reddit for jobs

Example: find remote React jobs posted in r/jobbit or r/reactjs this week.
### React jobs

Find remote React jobs posted in [r/jobbit](https://www.reddit.com/r/jobbit/) or [r/reactjs](https://www.reddit.com/r/reactjs/) this week.

```sh
node scripts/reddit/search.mjs \
Expand All @@ -18,7 +20,9 @@ node scripts/reddit/search.mjs \
-t 'week'
```

Example: find jobs mentioning "GCP" in various subreddits this month.
### GCP jobs

Find jobs mentioning "GCP" in various subreddits this month.

```sh
node scripts/reddit/search.mjs \
Expand All @@ -27,6 +31,18 @@ node scripts/reddit/search.mjs \
-t 'month'
```

### Lead generation for website audits

Find out whether someone is complaining about having a slow website this month.

```sh
node scripts/reddit/search.mjs \
-d 'Find out whether someone is complaining about having a slow website' \
-k 'audit,slow website, web performance' \
-s 'advancedentrepreneur,eCommerce,SaaS,smallbusiness' \
-t 'month'
```

## Search Reddit for keywords

Search a list of subreddits for posts containing any of the specified keywords, either in the title of the post, or in its body.
Expand All @@ -50,16 +66,6 @@ node scripts/reddit/search.mjs \
-t 'month'
```

Example (WIP): find leads for website audits.

```sh
node scripts/reddit/search.mjs \
-d 'Find out whether someone is complaining about having a slow website' \
-k 'audit,web performance,slow website' \
-s 'advancedentrepreneur,eCommerce,SaaS,smallbusiness' \
-t 'month'
```

Example: find out if anyone has ever talked about Elysia or Hono on any programming subreddit.

```sh
Expand All @@ -69,7 +75,9 @@ node scripts/reddit/search.mjs \
-t 'all'
```

Note: the [Steampipe Reddit plugin](https://hub.steampipe.io/plugins/turbot/reddit) seems **not** to allow searches across all Reddit. That's why I'm using [snoowrap](https://github.com/not-an-aardvark/snoowrap) for this script.
> :warning: **Don't use Steampipe for this query**
>
> The [Steampipe Reddit plugin](https://hub.steampipe.io/plugins/turbot/reddit) seems **not** to allow searches across **all** Reddit. That's why I'm using [snoowrap](https://github.com/not-an-aardvark/snoowrap) for this query.
You can also run this script from a GitHub workflow. For example, using the [GitHub CLI](https://cli.github.com/):

Expand Down
9 changes: 6 additions & 3 deletions scripts/reddit/search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const SUBREDDITS = [
]

const DEFAULT = {
DESCRIPTION: 'Query description not provided',
DESCRIPTION: `Search any of these keywords in ${SUBREDDITS.length} subreddits: ${KEYWORDS.join(', ')}`,
KEYWORDS,
SUBREDDITS,
TIME: 'week'
Expand Down Expand Up @@ -91,8 +91,11 @@ const searchOnReddit = async () => {
let query = ''
if (argv.query) {
query = argv.query
debug(`query provided: ${query}`)
} else {
debug(`query not provided, using keywords`)
const keywords = argv.keywords.split(',')
debug(`keywords provided: ${keywords}`)
const s = keywords
.map((k) => `selftext:"${k}" OR title:"${k}"`)
.join(' OR ')
Expand Down Expand Up @@ -138,8 +141,8 @@ const renderTelegramMessage = (d) => {
})
let s = `<b>${EMOJI.Robot} Reddit search</b>`

s = `${s}\n\n<b>Description</b>\n`
s = s.concat(`<pre>${d.description}</pre>`)
s = `${s}\n\n<b>Description</b>`
s = `${s}\n${d.description}`

s = `${s}\n\n<b>Results</b>\n`
if (links.length === 0) {
Expand Down

0 comments on commit 37737bd

Please sign in to comment.